My work for Hoon 101. Will remain private until the class is over.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

25 行
776B

  1. :: Hoon 101: Assignment 3a. Comment each line of code to tell the reader what the code is doing.
  2. :: Comments should be written as "breathing comments" as suggested in the Hoon Style Guide: https://urbit.org/docs/learn/hoon/style/
  3. :: create a gate, with the sample @ud, given the face n
  4. ::
  5. |= n=@ud
  6. :: attach a 't' faced @ud to the subject, with the value 1
  7. ::
  8. =/ t=@ud 1
  9. :: create and execute a gate, such that we can recurse back to this point
  10. ::
  11. |-
  12. :: if n is 1, return the next child, otherwise the one after
  13. ::
  14. ?: =(n 1)
  15. :: at the end, return our total
  16. ::
  17. t
  18. :: otherwise recurse with n minus one,
  19. :: and t multiplied by n. note t is
  20. :: not reset with the recurse, as it
  21. :: is attached before our recurse point
  22. ::
  23. $(n (dec n), t (mul t n))