[Haskell-cafe] Re: Reinvention

J. Garrett Morris trevion at gmail.com
Wed Jun 27 15:31:07 EDT 2007


More generally, that's unfoldr:

Prelude> :t Data.List.unfoldr
Data.List.unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

unfoldr represents the end of the unfold explicitly (using Nothing)
instead of implicitly (using the empty list).

 /g

On 27 Jun 2007 20:26:56 +0100, Jon Fairbairn <jon.fairbairn at cl.cam.ac.uk> wrote:
> Andrew Coppin <andrewcoppin at btinternet.com> writes:
>
> > I seem to be forever writing code that looks like this:
> >
> > decode :: String -> (SKI,String)
> > decode (c:cs) = case c of
> >   'S' -> (S,cs)
> >   'K' -> (K,cs)
> >   'I' -> (I,cs)
> >   '*' -> let (e0,cs0) = decode cs; (e1,cs1) = decode cs1 in (e0 :@: e1, cs1)
>
> This looks like parsing to me.
>
> --
> Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


-- 
The man who'd introduced them didn't much like either of them, though
he acted as if he did, anxious as he was to preserve good relations at
all times. One never knew, after all, now did one now did one now did
one.


More information about the Haskell-Cafe mailing list