[Haskell-beginners] ignature for a list of a set length

edgar klerks edgar.klerks at gmail.com
Tue Sep 28 11:04:47 EDT 2010


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 <ozgurakgun at gmail.com> wrote:

> Hi,
>
>
> On 28 September 2010 15:07, Martin Tomko <martin.tomko at geo.uzh.ch> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100928/fe3561bf/attachment-0001.html


More information about the Beginners mailing list