Test compilation routines.

This commit is contained in:
C. Guy Yarvin 2014-01-29 16:16:10 -08:00
parent f2671c43b9
commit d3795cad50
2 changed files with 177 additions and 0 deletions

165
arvo/test.hoon Normal file
View File

@ -0,0 +1,165 @@
!::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: :::::: Preface ::::::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
?> ?=(@ .) :: atom subject
%. . :: fun with subject
|= cud=@ :: call it cud
=- (mul:all 2 cud) :: multiply by 2
^= all :: assemble engine
=~ :: volume stack
%164 :: version constant
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: :::::: volume 0, version stub ::::::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
~% %k.164 ~ ~ ::
|% ::
++ stub 164 :: version stub
-- ::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: :::::: volume 1, Hoon models ::::::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
~% %mood
+
~
|% ::
++ axis ,@ :: tree address
-- ::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::: :::::: volume 2, Hoon libraries and compiler ::::::
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
~% %hoon
+
==
%dec dec
==
|%
::::::::::::::::::::::::::::::::::::::::::::::::::::: ::
:::: chapter 2a, basic unsigned math ::::
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
++ add :: add
~/ %add
|= [a=@ b=@]
^- @
?: =(0 a)
b
$(a (dec a), b +(b))
::
++ cap :: tree head
~/ %cap
|= a=@
^- ?(%2 %3)
?- a
%2 %2
%3 %3
?(%0 %1) !!
* $(a (div a 2))
==
::
++ dec :: decrement
~/ %dec
|= a=@
?< =(0 a)
=+ b=0
|- ^- @
?: =(a +(b))
b
$(b +(b))
::
++ div :: divide
~/ %div
|= [a=@ b=@]
^- @
?< =(0 b)
=+ c=0
|-
?: (lth a b)
c
$(a (sub a b), c +(c))
::
++ gte :: greater-equal
~/ %gte
|= [a=@ b=@]
^- ?
!(lth a b)
::
++ gth :: greater-than
~/ %gth
|= [a=@ b=@]
^- ?
!(lte a b)
::
++ lte :: less-equal
~/ %lte
|= [a=@ b=@]
|(=(a b) (lth a b))
::
++ lth :: less-than
~/ %lth
|= [a=@ b=@]
^- ?
&(!=(a b) |-(|(=(0 a) &(!=(0 b) $(a (dec a), b (dec b))))))
::
++ mas :: tree body
~/ %mas
|= a=@
^- @
?- a
1 !!
2 1
3 1
* (add (mod a 2) (mul $(a (div a 2)) 2))
==
::
++ max :: maximum
~/ %max
|= [a=@ b=@]
^- @
?: (gth a b)
a
b
::
++ min :: minimum
~/ %min
|= [a=@ b=@]
^- @
?: (lth a b)
a
b
::
++ mod :: remainder
~/ %mod
|= [a=@ b=@]
^- @
?< =(0 b)
(sub a (mul b (div a b)))
::
++ mul :: multiply
~/ %mul
|= [a=@ b=@]
^- @
=+ c=0
|-
?: =(0 a)
c
$(a (dec a), c (add b c))
::
++ peg :: tree connect
~/ %peg
|= [a=@ b=@]
^- @
?- b
1 a
2 (mul a 2)
3 +((mul a 2))
* (add (mod b 2) (mul $(b (div b 2)) 2))
==
::
++ sub :: subtract
~/ %sub
|= [a=@ b=@]
^- @
?: =(0 b)
a
$(a (dec a), b (dec b))
--
. ==

12
try/bin/till.hoon Normal file
View File

@ -0,0 +1,12 @@
!:
:: /=try=/bin/till/hoon
::
=> .(- `[who=@p how=path]`-)
|= [est=time eny=@uw]
|= [pax=path ~]
^- bowl
=+ gen=(reck pax)
=+ ken=q:(~(mint ut %noun) %noun gen)
=+ pac=(jam ken)
:_ ~ :_ ~
[%xx %save [%test %pill ~] pac]