From f918091ec8cc0e0b3d1f30bc3797299d10901258 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 7 Jun 2024 22:35:59 -0400 Subject: [PATCH] wip: optimize +ask:qui (pending +hub jet) --- hoon/codegen/lib/skan.hoon | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/hoon/codegen/lib/skan.hoon b/hoon/codegen/lib/skan.hoon index 3d797b0..86faf29 100644 --- a/hoon/codegen/lib/skan.hoon +++ b/hoon/codegen/lib/skan.hoon @@ -719,12 +719,25 @@ ++ ask |= axe=@ ?< =(0 axe) + =/ rev 1 + =| don=(list (pair @ (list peon))) |- ^- prot - ?: =(1 axe) prog - ?- (cap axe) - %2 $(axe (mas axe), prog hed) - %3 $(axe (mas axe), prog tal) - == + =+ [n l r]=?@(prog [~ ~ ~] prog) + ?. =(1 axe) + ?- (cap axe) + %2 $(axe (mas axe), don [[rev n] don], rev (peg rev 2), prog l) + %3 $(axe (mas axe), don [[rev n] don], rev (peg rev 3), prog r) + == + =. n + %+ roll don + |= [[axe=@ lit=(list peon)] out=_n] + ?: =(~ lit) out + =/ rel (hub axe rev) + %+ roll lit + |=([p=peon =_out] [p(axe (peg axe.p rel)) out]) + ?: ?&(?=(~ n) ?=(~ l) ?=(~ r)) ~ + [n l r] + :: ++ put |= [axe=@ poor=prot] ?< =(0 axe) @@ -846,6 +859,21 @@ %+ turn slav |= =peon peon(axe (peg axe.peon axe)) +:: +++ hub + :: ~/ %hub + :: 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)) +:: ++ dif-ju |* a=(jug) |* b=_a