Created
July 29, 2019 18:22
-
-
Save urcades/02d00ae9b674cde229da81461a3b97dc to your computer and use it in GitHub Desktop.
Hoon 101 Assignment 3 (Combined files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: 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)) | |
:: | |
:: 3B | |
:: | |
:: I managed to figure out how to get a simple | |
:: atom-only list checker running, but I struggled | |
:: to figure out how to get strings rendered as their | |
:: initial textual aura instead of @ud-type output | |
:: | |
:: I was curious why I needed to use '2' as my count | |
:: number, as other examples I saw in the tutorial (snag.hoon) | |
:: allowed the user to specify their "selection point | |
:: and have it represented in the output just fine, i.e: | |
:: using an input of "3" in snag.hoon would actually get the third list item. | |
|= n=(list @) | |
=/ a=@ud 2 | |
|- | |
?~ n !! | |
?: =(0 a) i.n | |
$(a (dec a), n t.n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment