[Haskell-beginners] Re: Non-recursive binding expression

Will Ness will_n48 at yahoo.com
Sat Feb 28 12:19:03 EST 2009


 <j.romildo <at> gmail.com> writes:

> 
> Hello.
> 
> Is there any non-recursive binding expression in Haskell?
> 
> Something that would allow me to write, for instance,
> 
>   test = let' xs = [] in
>          let' xs = 3 : xs in
>          let' xs = 8 : xs in
>          let' xs = 7 : xs in
>          xs
> 
> Here let' is an hypothetical construction similar to let, except that it
> would be non-recursive. In the example, the value of test would be
> [7,8,3].
> 
> So, is there something in this line in Haskell?
> 
> Regards,
> 
> José Romildo
> 


Well, it's not a nice thing to do (probably), but you can write

test = head $ 
  do xs <- [ [] ]
     xs <- [ 3:xs ]
     xs <- [ 8:xs ]
     xs <- [ 7:xs ]
     return xs





More information about the Beginners mailing list