62 lines
1.9 KiB
Plaintext
62 lines
1.9 KiB
Plaintext
( A
|
|
= m n value key eq chain
|
|
, find insert future stack va val
|
|
. ( chain
|
|
= key future skey
|
|
. !arg:(?key.?future)
|
|
& str$!key:?skey
|
|
& (cache..insert)$(!skey..!future)
|
|
&
|
|
)
|
|
& (find=.(cache..find)$(str$!arg))
|
|
& ( insert
|
|
= key value future v futureeq futurem skey
|
|
. !arg:(?key.?value)
|
|
& str$!key:?skey
|
|
& ( (cache..find)$!skey:(?key.?v.?future)
|
|
& (cache..remove)$!skey
|
|
& (cache..insert)$(!skey.!value.)
|
|
& ( !future:(?futurem.?futureeq)
|
|
& (!futurem,!value.!futureeq)
|
|
|
|
|
)
|
|
| (cache..insert)$(!skey.!value.)&
|
|
)
|
|
)
|
|
& !arg:(?m,?n)
|
|
& !n+1:?value
|
|
& :?eq:?stack
|
|
& whl
|
|
' ( (!m,!n):?key
|
|
& ( find$!key:(?.#%?value.?future)
|
|
& insert$(!eq.!value) !future
|
|
| !m:0
|
|
& !n+1:?value
|
|
& ( !eq:&insert$(!key.!value)
|
|
| insert$(!key.!value) !stack:?stack
|
|
& insert$(!eq.!value)
|
|
)
|
|
| !n:0
|
|
& (!m+-1,1.!key)
|
|
(!eq:|(!key.!eq))
|
|
| find$(!m,!n+-1):(?.?val.?)
|
|
& ( !val:#%
|
|
& ( find$(!m+-1,!val):(?.?va.?)
|
|
& !va:#%
|
|
& insert$(!key.!va)
|
|
| (!m+-1,!val.!eq)
|
|
(!m,!n.!eq)
|
|
)
|
|
|
|
|
)
|
|
| chain$(!m,!n+-1.!m+-1.!key)
|
|
& (!m,!n+-1.)
|
|
(!eq:|(!key.!eq))
|
|
)
|
|
!stack
|
|
: (?m,?n.?eq) ?stack
|
|
)
|
|
& !value
|
|
)
|
|
& new$hash:?cache
|