From 43c7d1e262fc3646b59853bacba43049a09ef46b Mon Sep 17 00:00:00 2001 From: tA Date: Tue, 16 Jul 2019 10:41:36 +1200 Subject: [PATCH] week2 --- README.md | 4 ++++ week1/week1.hoon | 1 + week2/week2.hoon | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 week2/week2.hoon diff --git a/README.md b/README.md index 2d90e2a..cc83841 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/week1/week1.hoon b/week1/week1.hoon index 9d068f8..e315df3 100644 --- a/week1/week1.hoon +++ b/week1/week1.hoon @@ -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 + diff --git a/week2/week2.hoon b/week2/week2.hoon new file mode 100644 index 0000000..6c45d0c --- /dev/null +++ b/week2/week2.hoon @@ -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" ::