Does (</.~ f) data  do what you want?

-Dan


Please excuse typos; composed on a handheld device.

-----Original Message-----
From: "John Randall" <[email protected]>
Sender: [email protected]
Date: Wed, 22 Sep 2010 13:41:35 
To: <[email protected]>
Reply-To: Programming forum <[email protected]>
Subject: [Jprogramming] Classification problem

I'm looking for help with a simple programming problem.

Suppose my data consists of integers, and I have a classification to a
small number of values.

For example

f=:1+*
data=:_3 1 0 1 _1 0 _10 _2 _4 6

    f data
0 2 1 2 0 1 0 0 0 2

I then want to organize the data into boxes based on these values, for
example

+---------------+---+-----+
|_3 _1 _10 _2 _4|0 0|1 1 6|
+---------------+---+-----+

I got this using

(0 1 2=/f data) <@# data

Is there a simpler or better way?

Best wishes,

John

----------------------------------------------------------------------
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