
2009/5/5 applebiz89
Hi, I think I need to use a list comprehension for this function but Im not good with list comprehension. this is what I have so at the moment?
filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear ?= [ title | year <- (Film title director year fans) , year == filmYear] (this code wont compile - error given '?Syntax error in expression (unexpected `;', possibly due to bad layout)')
Is there an alternative solution instead of comprehension? I want the function to be given a release date and then return all films with that date.
Hi, I suggest you start by some simple examples, then move to your goal. For instance you can try to write a function which takes in input a list of Int and outputs a list of those Int that are odd. f [1,2,3,4,5] => [1,3,5] You can generalise this function to accept a predicate. g even [1,2,3,4,5] => [2,4] Returning back to your problem, can you write a function that takes a Film and returns its release date ? Then you can write a function which test if that date match a given one. Then, finally, you can write a function which get a list of Film and outputs only those satisfying your desire. Cheers, Thu