UP

Function lex∆assign


Definition

    ∇ nx←lx lex∆assign item;ix;keys;keyShape
[1]    ⍝⍝ Function to assign a value to a key where larg is the lexicon and
[2]    ⍝⍝ rarg is a key value pair. Pair will be added if the key is not in
[3]    ⍝⍝ the lexicon.
[4]    nx←lx
[5]    →(' '≠1↑0⍴⊃item[1])/err
[6]    ⍝ Test for empty lexicon
[7]    →(0=1↑⍴nx)/add
[8]    keyShape←⍴keys←⊃nx[;1]
[9]    ix←(keys∧.=keyShape[2]↑⊃item[1])/⍳keyShape[1]
[10]   →(0=⍴ix)/add
[11] replace:
[12]   nx[ix;2]←item[2]
[13]   →0
[14] add:
[15]   nx←nx,[1]item
[16]   →0
[17] err:
[18]   ⍞←'Lexicon entries must use a character string as a key'
[19]   →0
    ∇

Call Graph (defined functions called from function lex∆assign)