5# `:door`, `|_`, "buccab", `{$door p/moss q/(map term twig)}`
7Door: core with sample (input values).
9Produces: a core whose sample is `p` and arms are `q`.
11Regular form: *1-fixed*, then *battery*
13Similar to `|%`, but also takes input data (aka sample)
14available within the entire core. Cores of this type are called doors.
15Moreover, `|_` only accepts dry or `%elm` arms--in other words,
16type checking on these arms is performed on the input before computation.
25 /~zod/try=> ~(succ mol 1)
27 /~zod/try=> ~(succ mol ~(succ mol ~(prev mol 5)))
30In this example we create a door `mol` that operates on a `@ud`,
31`a`. We add two arms to our door, `++succ` and `++prev`, and invoke them
32with the irregular form of `%~`. Doors are commonly invoked with
33`%~`, irregular form `~(arm door sample)`, which replaces the door's
34sample and calls the specified arm.
48 /~zod/try=> ~(tal kom "abc")
50 /~zod/try=> ~(tal kot "abc")
52 /~zod/try=> ~(tal kot [1 2 3 ~])
54 /~zod/try=> ~(tal kom [1 2 3 ~])
57Here we're demonstrating the difference between `|_` and `|/`. We create
58a nearly identical door using both runes, each with an arm that produces
59the tail of the sample `a`. You can see that wet functions use the
60sample as a mold to produce well-typed output.
65 ++ x ?:((gte tig 10) (add tig 87) d)
66 ++ v ?:((gte tig 10) (add tig 87) d)
67 ++ w ?:(=(tig 63) '~' ?:(=(tig 62) '-' ?:((gte tig 36) (add tig 29) x)))
71`++ne` is used to print a single digit in base 10, 16, 32, or 64 and is
72a part of the hoon standard library. You can find it in `hoon.hoon`.
73`|_` is very commonly used throughout our standard library for groups of
74arms who all take the same sample.
78 ~zod/try=> `@t`~(x ne 12)
83Here we put `++ne` to work a bit. Our first call renders 12 in base 16.
84Since `99` is within the ASCII character range, we can cast it to a
85`@t` and get `'c'`. Conveniently, casting `12` to a `@ux`
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list