Skip to content

Instantly share code, notes, and snippets.

@urcades
Created July 29, 2019 18:19
Show Gist options
  • Save urcades/878cbebfa089caf825b678c6b8c8a82c to your computer and use it in GitHub Desktop.
Save urcades/878cbebfa089caf825b678c6b8c8a82c to your computer and use it in GitHub Desktop.
Hoon 101 Assignment 3A
:: Line 3: We are creating a naked generator that accepts a @ud-typed face we're naming 'n'
::
|= n=@ud
:: Line 6: Within the initial generator, we're setting a new face (with value) to be used in the recursion below — a @ud-typed face named 't'
::
=/ t=@ud 1
:: Line 9: The rune "barhep" sets our recursion point: Everything after this rune loops until a terminating clause is met
::
|-
:: Line 12: The rune 'wutcol' branches execution based on a boolean test — it is asking, "is face 'n' equivalent to the atom 1?"...
::
?: =(n 1)
:: Line 15: ... if the previous line's test evaluates to 'true', the program simply resolves to 'true' in hoon ...
::
t
:: Line 18: ... if the test on Line 12 evaluates to false, Line 18 is run, which is a recursion statement of the initial subject/scope's 'wutcol' rune (which is within the gate on Line 9), with changed samples
::
$(n (dec n), t (mul t n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment