May be slightly better to use a temporary instead of repeating "f y" (see
"upfltr4" below):
upfltr2=: 4 : 0
NB. update filtered y. x updateV`fltrV,
'`up f' =. x
(f y)}y,:up y
)
zz=. 1e4?1e9
6!:2 '+:`(10&>) upfltr2 zz'
0.0019156066 NB. Not as fast...
6!:2 '+:`(10&>) upfltr zz'
0.00057269849
upfltr3=: 4 : 0
NB. update filtered y. x updateV`fltrV,
'`up f' =. x
(up y#~f y) (I. f y) } y
)
+:`(10&>) upfltr3 5 9 11 12
10 18 11 12
6!:2 '+:`(10&>) upfltr3 zz'
0.00056320007 NB. Basically the same...
upfltr4=: 4 : 0
NB. update filtered y. x updateV`fltrV,
'`up f' =. x
xx=. f y
(up xx#y) (I. xx)}y
)
6!:2 '+:`(10&>) upfltr4 zz'
0.00045368895 NB. Marginally faster? Hard to conclude...
On 4/19/06, Pascal Jasmin <[EMAIL PROTECTED]> wrote:
>
> NB. update only selected items from y with monad
> function of y, leave rest unchanged.
> upfltr =: 4 : 0
> NB. update filtered y. x updateV`fltrV,
> '`up f' =. x
> (up (I. f y){ y) (I. f y) } y
> )
> NB. double items greater than 10:
> +:`(10&>) upfltr 5 9 11 12
> 10 18 11 12
>
> is there a faster way to implement the above? Seems
> to me the above verb should be one of the built-in
> gerund ammend options, (maybe it is, and I just don't
> understand the documentation for it).
>
...
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm