logo       

Re: Guards: msg#00132

lang.haskell.cafe

Subject: Re: Guards


On Sat, 8 Jan 2005, Lemming wrote:

> Jon Cast wrote:
>
> > Absolutely. In Haskell's syntax, if-then-else-if interacts badly with
> > do notation, and Haskell lacks a direct analogy to Lisp's cond.
> >
> > case () of
> > () | p1 -> e1
> > | p2 -> e2
> > ...
>
> No problem:
>
> select :: a -> [(Bool, a)] -> a
> select def = maybe def snd . List.find fst

Alternatively:
select def = fromMaybe def . lookup True


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise