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 <[EMAIL PROTECTED]> wrote:
Andrew Coppin <[EMAIL PROTECTED]> 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                                 [EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to