Re: [Haskell-cafe] Re: [Haskell] Trying to get a Composite design pattern to work

2006-03-14 Thread Chris Kuklewicz
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

Re: [Haskell-cafe] Re: [Haskell] Trying to get a Composite design pattern to work

2006-03-14 Thread Chris Kuklewicz
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

Re: [Haskell-cafe] Re: [Haskell] Trying to get a Composite design pattern to work

2006-03-13 Thread Neil Mitchell
> 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

[Haskell-cafe] Re: [Haskell] Trying to get a Composite design pattern to work

2006-03-13 Thread Asfand Yar Qazi
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

[Haskell-cafe] Re: [Haskell] Trying to get a Composite design pattern to work

2006-03-13 Thread Jared Updike
(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