
And if that isn't a possibility, you can use pattern matching:
bla (x:y:z:[]) = do something
bla _ = do nothing
On Tue, Sep 28, 2010 at 4:41 PM, Ozgur Akgun
Hi,
On 28 September 2010 15:07, Martin Tomko
wrote: I want to have a function that acts only on lists of length 3 (I have a function that filters a list of lists and returns only those of that length). I guess I could change them into tuples (is there a way?)
Well if both the producer and the consumer of this value are your own functions, you can use something other than a list. You can also implement a length indexed list, or use such an implementation but it will be overkill for this task, I think.
The two options are either implementing a wrapper type with three fields, or using a 3-tuple. I would use a 3-tuple in both the producer and consumer functions.
Best, Ozgur
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners