hoon: added +repn

This commit is contained in:
Logan Allen 2020-01-29 15:51:19 -08:00
parent deb3d26d3f
commit a025a7fcb0
2 changed files with 10 additions and 6 deletions

View File

@ -59,7 +59,7 @@
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
::
|^ |= bs=octs ^- cord
=/ [padding=@ blocks=(list word24)]
=+ ^- [padding=@ blocks=(list word24)]
(octs-to-blocks bs)
(crip (flop (unpad padding (encode-blocks blocks))))
::
@ -127,10 +127,6 @@
=/ len (sub (mul 3 (div (add lat dif) 4)) dif)
:+ ~ len
%+ swp 3
:: %+ base 64
%+ roll
(weld dat (reap dif 0))
|=([p=@ q=@] (add p (mul 64 q)))
(repn 6 (flop (weld dat (reap dif 0))))
--
--

View File

@ -867,6 +867,14 @@
?~ b 0
(add (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
::
++ repn
~/ %repn
|= [bits=@ud x=(list @)]
=| c=@ud
|- ^- @
?~ x 0
(add (lsh 0 (mul bits c) (end 0 bits i.x)) $(c +(c), x t.x))
::
++ rev
:: reverses block order, accounting for leading zeroes
::