ts'A example B'
0.19816404 149824
ts'(I.B)([>:@+{(1 i.~>:)>:@[}.])"0 _ A'
0.09702199 216000
(A example B)-:(I.B)([>:@+{(1 i.~>:)>:@[}.])"0 _ A
1
It would have saved me time if you had (also) stated the problem in English.
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Raul Miller
Verzonden: zondag 19 oktober 2008 19:26
Aan: Programming forum
Onderwerp: [Jprogramming] Re: next not greater
Yesterday, I wrote:
> example=:4 :0 NB. a example b
> c=.1+I.y
> while.1 e. s=.c >&({&x) I.y do.
> c=.c+s
> end.
> c
> )
>
> A=: 0,~ ([EMAIL PROTECTED])(-<./)+/\<:?.1e3#3
> B=: 0,~?.2#~<:#A
> (6!:2,7!:2) 'A example B'
> 0.306458 149824
>
> Can you do better than this?
I guess this problem must not be very interesting, but here's a
trivial change which gives me a 30% speedup:
example=:4 :0 NB. a example b
c=.1+Iy=.I.y
while.1 e. s=.c >&({&x) Iy do.
c=.c+s
end.
c
)
ts'A example B'
0.202472 149824
--
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