This commit is contained in:
Thorn Avery 2019-07-16 10:41:36 +12:00
parent 00d09fcbe2
commit 43c7d1e262
3 changed files with 19 additions and 0 deletions

View File

@ -5,3 +5,7 @@ My assignments for each week of Hoon 101.
## Week 1 ## Week 1
> Create a naked generator that takes an atom and returns the same atom cast to any aura > 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 its even or odd. The output should be of the tape type.

View File

@ -4,3 +4,4 @@
|= inp=@ :: 1 - create a gate with one atom input, 'inp' |= inp=@ :: 1 - create a gate with one atom input, 'inp'
^- @p :: 2 - use kethep to cast inp to a planet aura ^- @p :: 2 - use kethep to cast inp to a planet aura
inp :: 3 - close the kethep, and ergo close the bartis inp :: 3 - close the kethep, and ergo close the bartis

14
week2/week2.hoon Normal file
View 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" ::