[EMAIL PROTECTED] wrote:
> 
> I want to propose the following function slide, which is like map, but
> depends not on one value of
> a list, but on several consecutive ones.
> 
> slide :: ([a] -> b) -> [a] -> [b]
> slide f [] = []
> slide f xs = f xs : slide f (tail xs)

The function is interesting from the theoretical side since it is an instance of 
*redecoration*.  Written as

slide :: [a] -> ([a] -> b) -> [b] ,

one sees a similarity with the monadic multiplication (or substitution, here for the 
case of lists)

>>=   :: [a] -> (a -> [b]) -> [b] .

Indeed, slide is the multiplication operation of lists viewed as a *comonad* and hence 
the dual of ">>=".

Read more in

T Uustalu, V Vene. The dual of substitution is redecoration. In K Hammond, S Curtis, 
eds, Trends in Functional Programming 3, pp 99-110. Intellect,
      Bristol / Portland, OR, 2002. - .ps.gz, 46K (© Intellect) 

http://www.cs.ioc.ee/~tarmo/papers/sfp01-book.ps.gz ,

if you want to be bothered with categorical nonsence ;-)

Cheers,
Andreas

-- 
Andreas Abel     --<>--    What if Jesus is right?  

Theoretical Computer Science, University of Munich
http://www.tcs.informatik.uni-muenchen.de/~abel/
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to