Most k version support dictionaries. Might be worth to take a look.
But basically you operate on them with the same array symbols
and they do the expected beheaviour. So if x d: y would create a dict
with x for keys and y for values, k supports:

  dict1=:(a;b) d: 1 2
  dict2=:(b;c) d: 3 4
  dict1 + dict2
(a;b;c) d: 1 4 4
  dict1 -. dict2
(<a) d: 1
  (<a){dict1
1
  2 i. dict1
<b
  2 (<a)}dict1
(a;b) d: 2 2
  +/ dict1
3

I'm not sure how to formulate this intuitive beheaviour. Whenever an
array index is needed (like with i. or {), just the key is used.
Things like |. wouldn't make sense, so they would just operate on
the value rank. How to specify rank will probably induce some
headaches, too.

There must also be a way to deconstruct the dictionaries:
  k: dict1
(a;b)
  v: dict1
1 2
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to