[Haskell-cafe] Re: Problems interpreting

Andrea Rossato mailing_list at istitutocolli.org
Mon Sep 18 08:23:21 EDT 2006


On Mon, Sep 18, 2006 at 12:42:59PM +0100, Jón Fairbairn wrote:
> And if you do that, you can write it like this:
> 
>    subst e l'
>        = concat . map subst_elem
>          where subst_elem x
>                    | x == e = l'
>                    | otherwise = [x]

Pretty. Just to many keystrokes.
This should take two keystrokes less, probably:

subst e l [] = []
subst e l (x:xs) = if x == e then l ++ xs else x : subst e l xs

;-)
andrea


More information about the Haskell-Cafe mailing list