Same idea:

   si =: 1 i."1~ +./@:e.S:1"1 0

Henry Rich

On 11/13/2013 2:44 PM, R.E. Boss wrote:

    ss (1 i.~"1 (e.S:0"0 _;L:1))~ 1;13;8
1 4 3


R.E. Boss

(Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )


-----Original Message-----
From: [email protected] [mailto:programming-
[email protected]] On Behalf Of km
Sent: woensdag 13 november 2013 20:25
To: [email protected]
Subject: [Jprogramming] Finding elements

Think of ss below as a list of four sets; elements are in the inner boxes.
Verb
si gives the index of the first set in which an element is found.  Your
task is to
write verb si .

     ]ss =: (<0);(1;2);(3;4;5);< 6;7;8;9
  +---+-----+-------+---------+
  |+-+|+-+-+|+-+-+-+|+-+-+-+-+|
  ||0|||1|2|||3|4|5|||6|7|8|9||
  |+-+|+-+-+|+-+-+-+|+-+-+-+-+|
  +---+-----+-------+---------+

     ss si 1;13;8  NB. 1 in set 1, 13 not found, 8 in set 3
  1 4 3

--Kip Murray

Sent from my iPad
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

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

Reply via email to