I realize I'm late to the party, but going back to the ordered vs unordered
question. I saw rudimentary implementation of a hash table in another
language that used a set for the keys and a vector for the values. It's
more like an associative array instead of a hash table I think.

Using R.E Boss's
set=: <@~.

Here is a crude way to work with it

k=:set 'apple';'celery'

NB. add an item

]k=:set ((>k),<'banana')

+---------------------+

|+-----+------+------+|

||apple|celery|banana||

|+-----+------+------+|

+---------------------+


NB. create empty value vector
v=:(# >k) $ <''

NB. set a value

]v=:(<'fruit') ((>k) i. <'banana') } v

+++-----+

|||fruit|

+++-----+


NB. get a value

] ((>k) i. <'banana') { v

+-----+

|fruit|
+-----+


  ]v=:(<'vegetable') ((>k) i. <'celery') } v

++---------+-----+

||vegetable|fruit|

++---------+-----+


Just thought I'd point another application of sets


On Tue, Nov 19, 2013 at 6:15 AM, Brian Schott <[email protected]>wrote:

> The difference I see as fundamental is on the Empty set.
> Whereas in the previous proposal we got the following results.
>
>    $Empty
>
>    ps Empty
> |length error: ps
> |       ps Empty
>
> In the current proposal we get the following results.
>
>    $Empty
> 0
>    ps Empty
> ┌┐
> ││
> └┘
>
>
> In both proposals a difficulty arises with the execution of the following
> instruction because a set with the sole element "blank" is different from
> Empty. But I don't know a remedy.
>
>    set <''
>
>
> --
> (B=)
> ----------------------------------------------------------------------
> 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