Thank you, a better candidate for the haskell equivalent of scanl =: /\.(&.|.) but a more J like, freely combinable version is this adverb is scanl =: \.(&.|.) (missing the leading /)
< scanl i.6 +-+---+-----+-------+---------+-----------+ |0|1 0|2 1 0|3 2 1 0|4 3 2 1 0|5 4 3 2 1 0| +-+---+-----+-------+---------+-----------+ ----- Original Message ---- From: R.E. Boss <[EMAIL PROTECTED]> To: Programming forum <[email protected]> Sent: Tuesday, October 17, 2006 10:03:57 AM Subject: RE: [Jprogramming] understanding scan -/\.&.|. is equivalent to -/ &|. \ but much faster. (-/\.&.|. -: -/ &|. \)2 ^ i.1000 1 ts'-/\.&.|. 2^i.1000' 7.3942108e_5 30400 ts'-/ &|. \ 2 ^ i.1000' 0.0038858702 50944 R.E. Boss -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Pascal Jasmin Verzonden: dinsdag 17 oktober 2006 15:29 Aan: Programming forum Onderwerp: Re: [Jprogramming] understanding scan Thank you very much Raul, A very useful generic pattern whenever you want the partial function of element f leftsubtotaloflist is scanl =: @: |. \ f/ scanl DATA 2 ^ i.6 1 2 4 8 16 32 -/\ 2 ^ i.6 1 _1 3 _5 11 _21 -/ &|. \ 2 ^ i.6 1 1 3 5 11 21 The last expression is especially easy to track along as imperatively: subtotal[index] =. list[index] (f=. -) subtotal[index-1] The one issue I have no guess about is whether & @ &: or @: is the best conjunction to define scanl with. To match the haskell prelude, it should actually be defined as scanl =: /(@: |. \) and only matches the definition in the monad case anyway, which makes all of the conjunctions equivalent. Is there one of the above conjunctions that would make the first scanl definition useful/interesting in a dyad case? ----- Original Message ---- From: "Miller, Raul D" <[EMAIL PROTECTED]> To: Programming forum <[email protected]> Sent: Monday, October 16, 2006 6:00:04 PM Subject: RE: [Jprogramming] understanding scan I wrote: > (0 >. +)/&.|.\ a > > / is right to left, but gambler uses left to right. > /(&.|.) is left to right. &. is unnecessary and could cause problems in the general case (not this specific case). As & is sufficient, I should have said: (0 >. +)/&|.\ a and so on. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
