瀏覽代碼

better week2

master
Thorn Avery 4 年之前
父節點
當前提交
453fd47781
共有 1 個檔案被更改,包括 10 行新增11 行删除
  1. +10
    -11
      week2/week2.hoon

+ 10
- 11
week2/week2.hoon 查看文件

@@ -1,14 +1,13 @@
:: 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" ::
|= a=* :: take in any noun
^- 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 - " atom") :: attach a block to the head of the subject
?: =((mod a 2) 0) :: mod is safe because we know a isnt a cell
"an even" ::
"an odd" ::

Loading…
取消
儲存