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