HSL ~2022.2 %hw2
Homework #2 for Hoon School Live.

You have now learned how to use irregular syntax for Hoon runes, and should think about how to employ it when convenient.

You have learned about the following runes:

- `^+` ketlus, for enforcing a type (like `^-` but with an example)
- `^*` kettar, for producing an example (a bunt)
- `$?` bucwut, for producing a type union
- `$:` buccol, for producing a named tuple
- `!>` zapgar, for ascertaining the type of a value
- `|=` bartis, for creating a gate
- `::`, for commenting on code
- `!!` zapzap, for crashing or stubbing out incomplete branches of your Hoon expressions
- `/+` faslus, for importing a library of code
adambrettmalin@gmail.com Switch account
Email *
Q0. What is your planet or comet? (Type "our" in the Dojo of your ship to identify if you're not sure—your ship, not your fakeship.) *
Irregular Syntax
Many runes have irregular syntax. This can make it easier to write aesthetically expressive Hoon code.
Q1. Convert the irregular form `[1 2 3 4]` to a regular form. *
Q2. Convert the irregular form `(factorial 10)` to a regular form. *
Q3. Convert the regular form `^- @ud ^- @ 'two wolves'` to an irregular form. *
Molds
Molds define Hoon structures. They have a default value (“bunt”) and are strictly statically typed (i.e. they must match).
Q4. What is the bunt of `@da`? *
Q5. What is the bunt of `@uc`? *
Q6. What is the bunt of `@da` as a `@ud`? *
Q7. What is the bunt of `cell`? (I.e. there is a type in Hoon named `cell`, do it of that.) *
Q8. Produce a type union which can accept a signed or unsigned decimal integer. *
Q9. Produce a named tuple with three elements `x`, `y`, ad `z`, all of type `@rs` (real number, number with a fractional part). *
Q10. What does the infixed `^` ket do? E.g., `4^5`. (Infer from its behavior in the Dojo.) *
Deferring Computation
A gate (made with `|=` bartis) lets you store a computation for future use.

You can store a gate as a standalone reusable file called a generator.
Q11. Take your code for the boxcar function in the previous homework. Produce a gate which works for any `@ud` input value `x`. *
Captionless Image
Q12. Take your code for the boxcar function gate in the previous question. Produce a generator from the gate named `boxcar.hoon`. Don't forget to add at least one comment to explain its intent. *
Captionless Image
Q13. Write a generator which accepts the value of a planet as a `@p` and returns the next neighbor, also as a `@p`. The next neighbor of a planet is calculated by incrementing the numeric value of the planet's address by one. You will then need to convert it from `@ud` back to `@p`. (You don't need to filter for planet input or anything, just for `@p`.) For instance, the next neighbor of ~sampel-palnet is ~radbyr-fonlyr. *
Q14. Write a generator which accepts the value of a planet as a `@p` and returns the next neighbor and the previous neighbor as a *cell* of two `@p`s. The previous neighbor of a planet is calculated by decrementing the numeric value of the planet's address by one. You will then need to convert it from `@ud` back to `@p`. (You don't need to filter for planet input or anything, just for `@p`.) For instance, the previous neighbor of ~sampel-palnet is ~datwyn-lavrud. *
Q15. Write a generator which accepts the value of a planet as a `@p` and returns the parent star, also as a `@p`. The parent of a planet is calculated by taking the remainder after division by 65.536. You can obtain this value using the `++mod` gate or the `++dvr` gate. You will then need to convert it from `@ud` back to `@p`. (You don't need to filter for planet input or anything, just for `@p`.) For instance, the parent of ~sampel-palnet is ~talpur. *
Q16. Write a generator that takes a sample of 3 arguments—two @uds and a @tas (which will be one of %mul %sub %add %div), with branches to handle multiplication, division, addition and subtraction. Use a gate. Write ?: wutcol runes to branch for each @tas case and the .= dottis equality-checking rune to check for actual value of the input v. option. Use the standard library functions to do the actual work in those expressions. Confirm that you can input your three arguments and receive the desired result of the selected operation. E.g. assuming your generator is named calculator.hoon, `+calculator [4 5 %mul]` should yield 20. *
Q17. What are your biggest remaining concerns, points of misunderstanding or fuzzy understanding, or other feedback on Lesson 2?
A copy of your responses will be emailed to the address you provided.
Submit
Clear form
Never submit passwords through Google Forms.
reCAPTCHA
This form was created inside of Tlon Corporation. Report Abuse