Henning Thielemann <[EMAIL PROTECTED]> wrote:

> 
> On Wed, 18 Jun 2008, Achim Schneider wrote:
> 
> > Is there a generalisation of scan1, such that eg.
> >
> > foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]
> >
> > ?
> 
> What is the (1,2) for? 
> 
Specifying the relative indexes an element depends on. Ideally, it
should be generalised for n-ary functions.

> I could think of
> foo f = List.unfoldr (\ xt@(x:xs) -> Just (x, xs ++ [f xt]))
> 
> foo sum [0,1]  =  [0,1,1,2,3,5,8,13,21,34,...
>
I should elaborate:

foo (+) [0,1,4] (1,2) = _|_, as 4 isn't 0+1
foo (+) [0,1] (2,3) = [0,1,_|_,1,_|_,_|_]
foo (+) [0,1,1,2,3,5] (1,2) = [0,1,1,2,3,5,8,13,...]
foo (+) [1] (1,1) = [1,2,4,8,16,32,...]


If you allow for inverse functions, you could even say

foo (+-) [0,...,3,..] (1,2) = [0,0,0,...,0,0,1,1,2,3,5,...]


It seems like I'm searching for some primitive that lets me combine
lists and currying. Think of passing a matrix, with each column (or row,
if you prefer) separately uniquely typed, into a function.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to