-/\.&.|. 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

Reply via email to