Chris Kuklewicz wrote:
> Neil Mitchell wrote:
>>> How's this?
>> What about ++, in Haskell thats just an ordinary function, yet you are
>> using the library one in this case.
>
> (++) a b = foldr (:) b a
>
> or
>
> (++) = flip (foldr (:))
>
> so
>
> concat = foldr (flip (foldr (:))) []
>
> al
Neil Mitchell wrote:
>> How's this?
>
> What about ++, in Haskell thats just an ordinary function, yet you are
> using the library one in this case.
(++) a b = foldr (:) b a
or
(++) = flip (foldr (:))
so
concat = foldr (flip (foldr (:))) []
also
map = (\f -> foldr ((:).f) [])
thus
concatM
> How's this?
What about ++, in Haskell thats just an ordinary function, yet you are
using the library one in this case.
The other thing is that the first definition of my_concat_map is
entirely redundant, the second one handles both cases anyway.
Also, for completeness, you might be interested
On 3/13/06, Jared Updike <[EMAIL PROTECTED]> wrote:
>
> If you want a place to start, I would challenge you to expand the
> concatMap definition above with the definitions of concat and map, and
> then plug in the definition of foldr and see if you can make your own
> concatMap function. Maybe that
(Moved to haskell-cafe)
> Actually, I'm trying to avoid library functions, so I can learn the
> language and the functional way of thinking. How would one implement
> the concatMap function?
The Haskell 98 report gives possible implementations of standard functions:
http://haskell.org/onliner