소스 검색

week2

master
Thorn Avery 4 년 전
부모
커밋
43c7d1e262
3개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. +4
    -0
      README.md
  2. +1
    -0
      week1/week1.hoon
  3. +14
    -0
      week2/week2.hoon

+ 4
- 0
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.

+ 1
- 0
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


+ 14
- 0
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" ::

불러오는 중...
취소
저장