1 2 3 4 1 2 3 4 t1"(_ 0) 2 3 4       NB. all of x vs. each of y
0 0 1


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Ian Gorse
> Verzonden: dinsdag 10 november 2009 13:59
> Aan: Programming forum
> Onderwerp: [Jprogramming] Checking if the first element is the same as the
> last
> 
> Hi
> 
> I seem to be having a bit of trouble performing this idea.
> 
> I am trying to get a subset of a list, and comparing the first element
> against the last element of the result.
> 
> 
>     2 >\/ (1 2 3 4 1 2 3 4)
> 1 2
> 2 3
> 3 4
> 4 1
> 1 2
> 2 3
> 3 4
> 
> t1 =: 4 : '(_1{a) -: (0{ a=. y >\/ (x))'
>    1 2 3 4 1 2 3 4 t1 2
> 0
> 
> 
>    4 >\/ (1 2 3 4 1 2 3 4)
> 1 2 3 4
> 2 3 4 1
> 3 4 1 2
> 4 1 2 3
> 1 2 3 4
> 
>    1 2 3 4 1 2 3 4 t1 4
> 1
> 
> t1 works as intended, but I am having trouble making it work with more
> than one right argument at a time
> Here are my failed attempts.
> 
>    1 2 3 4 1 2 3 4 t1 2 3 4 NB. result should be 0 0 1
> 0
> 
>    1 2 3 4 1 2 3 4 t1"0 2 3 4
> |length error
> |   1 2 3 4 1 2 3 4     t1"0 2 3 4
> 
>    1 2 3 4 1 2 3 4 t1 each (2 3 4)
> |length error
> |   1 2 3 4 1 2 3 4     t1 each(2 3 4)
> 
>    (1 2 3 4 1 2 3 4) t1"0 (2 3 4)
> |length error
> |   (1 2 3 4 1 2 3 4)    t1"0(2 3 4)
> ----------------------------------------------------------------------
> 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