Here is my solution.  It took me several days to find it, so I was surprised at 
how quickly R. E. Boss responded!  Thanks also to Brian Schott, Henry Rich, and 
Pascal Jasmin.  --Kip Murray

   ss =: (<0);(1;2);(3;4;5);< 6;7;8;9
   
   si =: 1 i."1~ [: |: (e."1 >)~
   
   ss si 1;13;8
1 4 3

Sent from my iPad

> On Nov 13, 2013, at 1:44 PM, "R.E. Boss" <[email protected]> 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