On 6/9/07, June Kim <[EMAIL PROTECTED]> wrote:
I'd appreciate any suggestion for improvement -- better and more
elegant approaches.

Perhaps we should start by contrasting with a pattern such as
  (rv/.~kv)
where kv is your key verb and rv is your result verb.

For example if I take your first example, and try to write what
I think you described, I might eliminate the key verb entirely
and just write:
  (;~~.)/.~ 'aaaabbaacc'
+-+------+
|a|aaaaaa|
+-+------+
|b|bb    |
+-+------+
|c|cc    |
+-+------+

And I notice that I got a different result than you -- one more in
line with what SQL does with GROUP BY.   If I want the effect
of Unix's uniq, I can use a key verb
  unikey=: +/\@([EMAIL PROTECTED] {. 2~:/\])
  ((;~~.)/.~ unikey) 'aaaabbaacc'
+-+----+
|a|aaaa|
+-+----+
|b|bb  |
+-+----+
|a|aa  |
+-+----+
|c|cc  |
+-+----+

Anyways, /.~ captures most of the concept of GROUP BY, is simple
to type, and leaves the complexities to the specific cases which
need that complexity.  This, I think, is the right way to approach
these sorts of analogies.

But if I am missing your point, let me know.

Thanks,

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

Reply via email to