mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
hoon: add pin and awl arms to test and trim subaxes
This commit is contained in:
parent
2fe6cac423
commit
cce2b5c9ed
@ -226,6 +226,33 @@
|
||||
* (add (mod b 2) (mul $(b (div b 2)) 2))
|
||||
==
|
||||
::
|
||||
++ pin
|
||||
~/ %pin
|
||||
:: sub axis test
|
||||
::
|
||||
:: checks whether {b} addresses a subtree of the tree addressed by {a}.
|
||||
|= [a=@ b=@]
|
||||
?< =(0 a)
|
||||
?< =(0 b)
|
||||
|- ^- ?
|
||||
?: =(a 1) %&
|
||||
?: =((cap a) (cap b))
|
||||
$(a (mas a), b (mas b))
|
||||
%|
|
||||
++ awl
|
||||
~/ %awl
|
||||
:: axis after axis
|
||||
:: computes the remainder of axis {b} when navigating to {a}.
|
||||
:: (crashes if not `(pin a b)`)
|
||||
|= [a=@ b=@]
|
||||
?< =(0 a)
|
||||
?< =(0 b)
|
||||
|- ^- @
|
||||
?: =(a 1) b
|
||||
?: =((cap a) (cap b))
|
||||
$(a (mas a), b (mas b))
|
||||
!!
|
||||
::
|
||||
:: # %containers
|
||||
::
|
||||
:: the most basic of data types
|
||||
|
Loading…
Reference in New Issue
Block a user