This reverts commit 8e1e40d75b3ab15c194b6bf9570f3edc46e2de58. This reverts commit f073c490f9fd7c5abc033af4857df92229877de7. This reverts commit f187d2d7e01a54823f3e979af9bbd148b398e7e9. This reverts commit bc272862a73cfce1b118586ca39d3a377d841f1b. This reverts commit 30a397513f8890a3406dc7ab91c6e067e3bbfbbb. This reverts commit 4fc6856fb50d88c20a0f533392ca606641c5f38f. Conflicts: urb/urbit.pill urb/zod/base/lib/drum.hoon
1.6 KiB
bartis, |=
, %brts
Dry gate
|=
, is a synthetic rune that produces a dry %gold
gate with
sample $*(p)
, arm q
. A gate is a core with one arm, $
, the
empty name. |=
checks its input sample against its tile, p
.
|=
is similar to a function that takes a defined input and produces
the result of some computation. |=
differs from |*
in that its
typechecking occurs at compile-time to ensure that all inputs match its
sample tile.
See also
bartar, |*
, %brtr
Produces
Twig: [%brts p=tile q=twig]
Sample
Tall form
|= p
q
Wide form
|=(p q)
Irregular form
None
Examples
~zod/try=> =inc |=(a=@ +(a))
~zod/try=> (inc 20)
21
Here we create a very simple gate that increments its sample, a
. You
can think of |=
as similar to a straightforward function that takes
arguments.
++ add :: add
~/ %add
|= [a=@ b=@]
^- @
?: =(0 a)
b
$(a (dec a), b +(b))
In ++add, from hoon.hoon
, |=
creates a gate whose sample takes
two atoms labeled a
and b
, and whose arm evaluates an expression
that produces the sum of the atoms by decrementing a
until it is 0
and incrementing b
at each step. Here, $
is used for recursion,
calling the gate produced by |=
with a
replaced by (dec a)
and b
replaced by +(b)
.