From cce2b5c9ed3a0b1625e95d9216e272ab44485de0 Mon Sep 17 00:00:00 2001 From: Edward Amsden Date: Tue, 16 May 2023 18:09:09 -0500 Subject: [PATCH] hoon: add pin and awl arms to test and trim subaxes --- pkg/arvo/sys/hoon.hoon | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index c99289c90b..c28db59392 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -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