When it's just two (or a small fixed number) of 
verbs you can dispense with gerunds:

   ((+/&.>(-.b)#list) , $&.>b#list) /: /:b
+-+-+-+--+-+-+
|3|4|3|19|2|5|
+-+-+-+--+-+-+

Or, if you can afford to, apply both verbs to
the entire list and pick and choose from the
results:

   b} (+/&.> ,: $&.>) list
+-+-+-+--+-+-+
|3|4|3|19|2|5|
+-+-+-+--+-+-+



----- Original Message -----
From: Mike Powell <[EMAIL PROTECTED]>
Date: Wednesday, October 25, 2006 12:15 pm
Subject: [Jprogramming] Apply to items

> I have a list of vectors of two types. Each vector needs to be  
> processed by a monadic function according to the corresponding  
> element of a boolean. I'm trying to do this by constructing a 
> gerund  
> and applying this item by item to the list (with an explicit or  
> implied pre-open and post-box). I'm stuck. For example:
> 
> b =: 0 1 1 0 1 1
> g=:+/`$
> list=:1 2;3 4 5 6;8 8 8; 9 2 4 1 3;1 2; 5 5 5 5 5
> 
> (b{g) apply list
> 
> 3;4;3;19;2;5


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to