Bladeren bron

week2

master
Thorn Avery 4 jaren geleden
bovenliggende
commit
43c7d1e262
3 gewijzigde bestanden met toevoegingen van 19 en 0 verwijderingen
  1. +4
    -0
      README.md
  2. +1
    -0
      week1/week1.hoon
  3. +14
    -0
      week2/week2.hoon

+ 4
- 0
README.md Bestand weergeven

@@ -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.

+ 1
- 0
week1/week1.hoon Bestand weergeven

@@ -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
- 0
week2/week2.hoon Bestand weergeven

@@ -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" ::

Laden…
Annuleren
Opslaan