Any distrction |
Samoth
Producer
Registration Date: 21-08-2004
Posts: 49
|
|
I am writing this post purely to avoid answering the final question of my Computer science assessment. I have been scratching my head for hours. Tea just wont fix it, spliffs will just make me more apathetic. Anyone who is up for a challenge, here is the question (answers in Haskell by 4:00 tomorrow!!)
--6.
-- Who has borrowed the most videos in a given database?
-- Note that a list is returned; that allows for the possibility that
-- more than one person may have borrowed the maximum number.
--
-- Hint: you need to run through all the people in the database and to
-- test whether they have borrowed the maximum number (calculated using
-- the function maxLoan).
-- maxBorrow exampleBase = ["Greg","Annabelle"]
My solution is:
maxBorrow dBase = filter (isMax ln dBase) loanInfo
where loanInfo = findLoanInfo dBase
ln = map (loans dBase) (peopleIn dBase)
isMax :: Int -> Database -> Bool
isMax x dBase = x==maxLoan dBase
but it doesnt work.
Not expecting any answers, just trying to make the time go by.
__
Ur-Sag Zi-Ga-Ni Naphar Ajjabi Sharush! Sa-Par-Mah-Zu Diri La-Magiru Sin Su-La.
|
|
16-03-2005 21:07 |
|
|
Samoth
Producer
Registration Date: 21-08-2004
Posts: 49
|
|
I have decided to go and smoke (and try and work on a laptop).
I know this is a bad idea, im prepared for the risk. Still, if anyone can answer that question, id gladly have a victory smoke with them. c'mon ppl, free weed - an answer is all i need!!
__
Ur-Sag Zi-Ga-Ni Naphar Ajjabi Sharush! Sa-Par-Mah-Zu Diri La-Magiru Sin Su-La.
|
|
16-03-2005 21:35 |
|
|
djfreemc
Sponsor
Registration Date: 25-07-2003
Posts: 1,117
Helpfulness rating:
|
|
hmm don't really understand the syntax u're using, but I understand the problem and think I have an idea how to solve it.
step 1: find max number of loans (take the first in db, save that to variable, compare to next, if it's greater save that one, if not do nothing)
step 2: scan list for people with max number of loans.
go through the database, compare nr of loans to maxloan. If equal, copy loaner data to a new list, that list will be your result.
what u also might do to know how big the result list must be is run through it and count nr of maxloan occurences
__ The mysteries of the distorted snare...
Can't win if u don't play
This post has been edited 1 time(s), it was last edited by djfreemc: 16-03-2005 21:52.
|
|
16-03-2005 21:50 |
|
|
Halph-Price
Zombie Algorithm
Registration Date: 22-12-2004
Posts: 6,160
Helpfulness rating:
|
|
kinda like SQL. and don't you just hate the god damn algebra. all that abstract math that they teach in schools, is now more popular because of these computer courses. and the courses certinly make ful use of it.
i just dropped out of Computer Programmer this week, to partake in music production and engineering. good luck in your CS course.
__
|
|
17-03-2005 04:48 |
|
|
|