[clean-list] Partial application of list constructor

Edsko de Vries devriese at cs.tcd.ie
Thu Jun 29 14:56:56 MEST 2006


On Tue, Jun 20, 2006 at 01:03:00PM -0300, j.romildo at gmail.com wrote:
> Hello.
> 
> How can one do a partial application of the non-nullary list constructor
> in Clean?
> 
> In Haskell one can write:
> 
>   f x = (:) (x,x)
>   main = print (f 4 [(1,2),(3,0)])
> 
> And in Clean, how one would write the function f using a partial
> application of the list constructor?
> 
> f is equivalent to the Clean function
> 
>   g x ys = [(x,x) : ys]
> 
> Regards.

f x xs = [(x,x):xs]

Start = f 4 [(1,2),(3,0)]

As far as I know, there is no other way. Of course, you could define

cons x xs = [x:xs]

f x = cons (x,x)

Edsko


More information about the clean-list mailing list