Yes, this works for range. However, it doesn't fix mult without some boxing. My other model is in need of the same thing. It seems simpler there: instead of 2"0, do something like (2-(=<.)) or (1+>.@(-<.)) , and then put mult into boxes.
Marshall -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Raul Miller Sent: Sunday, January 23, 2011 4:46 PM To: Programming forum Subject: Re: [Jprogramming] Floating from On Sun, Jan 23, 2011 at 3:33 PM, Marshall Lochbaum <[email protected]> wrote: > One correction to ffrom2: > > ffrom2=:4 :0 "0 _ > x=.,>x > range=. { (<.,>.)&.> x > mult=. *// (,.~-.) (-<.) x > mult +/^:(#x)@:* range{y > ) > > Now it replicates all of your results. > > This version outperforms yours in speed and space: > 6!:2 '(<?20$0) ffrom i.20#2' > 5.51853 > 6!:2 '(<?20$0) ffrom2 i.20#2' > 1.44303 > 7!:2 '(<?20$0) ffrom i.20#2' > 1535325568 > 7!:2 '(<?20$0) ffrom2 i.20#2' > 666901632 > > However, I would like to see a version that only uses the one value if > an integer is given (mine uses two copies of the same value and gives > weight 1 to one of them and 0 to the other). Perhaps: range=. { (<.~.@,>.)&.> x ? -- 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
