drumnbass.be forum

drumnbass.be forum » Drumnbass scene » Offtopic banter » Any distrction
Go to the bottom of this page Any distrction
Author
Post
Samoth Samoth is a male
Producer


images/avatars/avatar-609.jpg

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.

__
Death Ur-Sag Zi-Ga-Ni Naphar Ajjabi Sharush! Sa-Par-Mah-Zu Diri La-Magiru Sin Su-La. Spliff
16-03-2005 21:07 Homepage of Samoth
Samoth Samoth is a male
Producer


images/avatars/avatar-609.jpg

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!!

__
Death Ur-Sag Zi-Ga-Ni Naphar Ajjabi Sharush! Sa-Par-Mah-Zu Diri La-Magiru Sin Su-La. Spliff
16-03-2005 21:35 Homepage of Samoth
djfreemc djfreemc is a male
Sponsor


images/avatars/avatar-89.jpg

Registration Date: 25-07-2003
Posts: 1,117

Helpfulness rating: 
10 Vote(s) - Average Rating: 9.40

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 Homepage of djfreemc
Samoth Samoth is a male
Producer


images/avatars/avatar-609.jpg

Registration Date: 21-08-2004
Posts: 49


Cheers for the response.

Thats kinda the idea i was going for but instead eliminating the non maximum elements from the list. Ill see if your way is better. The language is Haskell, its a bit odd!!

edit: It works!!!

This is the solution:

maxBorrow :: Database -> [Person]
maxBorrow dBase = map getMaxPerson maxList
where loanInfo = findLoanInfo dBase
maxList = filter (isMax dBase) loanInfo

isMax :: Database -> (Person, Int) -> Bool
isMax dBase (_,l) = l==maxLoan dBase

getMaxPerson :: (Person,Int) -> [Char]
getMaxPerson (p,_) = p

Cheers for the help!

__
Death Ur-Sag Zi-Ga-Ni Naphar Ajjabi Sharush! Sa-Par-Mah-Zu Diri La-Magiru Sin Su-La. Spliff

This post has been edited 1 time(s), it was last edited by Samoth: 17-03-2005 03:34.

17-03-2005 02:53 Homepage of Samoth
Halph-Price Halph-Price is a male
Zombie Algorithm


images/avatars/avatar-2869.gif

Registration Date: 22-12-2004
Posts: 6,160

Helpfulness rating: 
36 Vote(s) - Average Rating: 8.67

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.

__
Latest Songs of filth and taboo depravity
SpankMyFilth on SoundCloud
She's got a nasty mouth...
FREE DOWNLOADS

17-03-2005 04:48 Homepage of Halph-Price
drumnbass.be forum » Drumnbass scene » Offtopic banter » Any distrction