[Jprogramming] Comparing non scalar data.
Don Guinn
donguinn at pvtnetworks.net
Fri Jan 27 05:18:13 HKT 2006
Not true that <, > etc. only work with scalars.
1 2 3>2
0 0 1
They are scalar in the sense that the comparison is atom by atom. Their
rank is 0 0 0. Look at rank in help.
Mikl Kurkov wrote:
> Hi All!
> I'm working on my first program in J so I have some questions.
>
> I wonder what is perferable method to compare vectors?
> As I understand comparing functions like > <
> are working only with scalars. Also for >. <. .
> But sorting eats all other data. So one of my desisions was:
>
> max =: {: @: /:~ : ({: @: /:~ @: ([ ,: ])) " _
> min =: {. @: /:~ : ({. @: /:~ @: ([ ,: ])) " _
>
> less =: ( ([ -: min) *. (-. at -:)) " _
> more =: ( ([ -: max) *. (-. at -:)) " _
>
> It works but I think it dumb.
> Another aproach I see is to convert all data to numbers and compare them.
> But I don't like it too.
>
> Isn't it possible to use the same comparing routines that sorting does?
>
More information about the Programming
mailing list