My work for Hoon 101. Will remain private until the class is over.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

25 linhas
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))