week2
This commit is contained in:
parent
00d09fcbe2
commit
43c7d1e262
@ -5,3 +5,7 @@ My assignments for each week of Hoon 101.
|
||||
## Week 1
|
||||
|
||||
> Create a naked generator that takes an atom and returns the same atom cast to any aura
|
||||
|
||||
## Week 2
|
||||
|
||||
> Build a naked generator that takes a noun and checks if that noun is a cell or an atom. If that input noun is an atom, check if it’s even or odd. The output should be of the tape type.
|
||||
|
@ -4,3 +4,4 @@
|
||||
|= inp=@ :: 1 - create a gate with one atom input, 'inp'
|
||||
^- @p :: 2 - use kethep to cast inp to a planet aura
|
||||
inp :: 3 - close the kethep, and ergo close the bartis
|
||||
|
||||
|
14
week2/week2.hoon
Normal file
14
week2/week2.hoon
Normal file
@ -0,0 +1,14 @@
|
||||
:: Hoon School - Week 2
|
||||
:: ~bannum-magtus || s@p7.co.nz
|
||||
::
|
||||
|= a=* ::
|
||||
^- tape :: explicitly return a tape
|
||||
%- weld :: weld some strings to reduce repitition
|
||||
:- "input is " ::
|
||||
?: .?(a) :: first branch, test whether a is a cell
|
||||
"a cell" ::
|
||||
%- weld :- :: if not, take the atom branch
|
||||
?: =((mod (@ a) 2) 0) :: this cast is safe as we know a is an atom
|
||||
"an even" ::
|
||||
"an odd" ::
|
||||
" atom" ::
|
Loading…
Reference in New Issue
Block a user