You could always expose a derived function by wrapping it in a traditional one. You could then use a trigger function or a property to rebuild the hash table. A simple example of what you are trying to do:
Code: Select all
:Class Hash
:Field Public Instance Symbols
∇ setSymbols
:Implements Trigger Symbols
⍝ Rebuild hash
hashFn←Symbols∘⍳
∇
∇ r←Find obj
:Access Public Instance
r←hashFn,obj
∇
∇ new
:Access Public Instance
:Implements Constructor
Symbols←⍬
∇
∇ new_1 symbols
:Access Public Instance
:Implements Constructor
Symbols←symbols
∇
hashFn←{}
:EndClass
And then to use it:
Code: Select all
h←⎕NEW Hash
h.Find'me'
1 1
h2←⎕NEW Hash
h.Symbols←'me' (⍳6) h2 (2 3 4⍴⍳12)
h.Find h2
3
h.Find(⍳6)'me'
2 1