My work for Hoon 101. Will remain private until the class is over.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

37 рядки
912B

  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))
  24. :: Hoon 101 - Week 3 Assignment
  25. :: ~bannum-magtus | s@p7.co.nz
  26. ::
  27. |= a=(list *)
  28. =/ n=@ud 1
  29. |-
  30. ?~ a
  31. %napoleonesque-list
  32. ?: =(3 n)
  33. i.a
  34. $(n +(n), a t.a)