Something like scan1

Is there a generalisation of scan1, such that eg. foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...] ? I came up with it while thinking about the equivalence of laziness and strictness resp. pull and push. To be more specific, I was thinking about ArrowLoop and how that beast generalises over time-varying values. It's some kind of helixoid fixed point (which might not help at all if your visualisation is incompatible with mine). -- (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.

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? 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,...

Henning Thielemann
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.

On Wed, 18 Jun 2008, Achim Schneider wrote:
Henning Thielemann
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.
foo f prefix (n,m) = let k = length prefix xs = prefix ++ zipWith f (xss!!(k-n)) (xss!!(k-m)) xss = List.tails xs in xs
participants (2)
-
Achim Schneider
-
Henning Thielemann