mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-24 23:44:56 +03:00
6cbb6b060d
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.5 KiB
1.5 KiB
cencab, %_
, %cncb
Evaluate with changes, cast
%_
is a synthetic rune that evaluates p
with the changes specified
in q
, then casts the product back to the type of p
. %_
is used to
change a batch of ++wing
s all at once, ensuring that the resulting
product is type checked.
See also
%=
is similar, but without type-checking.
Produces
Twig: [%cncb p=wing q=tram]
Sample
p
is a ++wing
, a list of ++limb
s. q
is a ++tram
, a
list of ++wing
s and twigs.
Tall form
%_ p
p.i.q q.i.q
p.i.t.q q.i.t.q
==
Wide form
%_(p p.i.q q.i.q, p.i.t.q q.i.t.q)
Irregular form
None
Examples
/~zod/try=> =a [b=1 c=2 d=3]
new var %a
/~zod/try=> %_(a b (add 3 b.a), c (add 3 c.a), d (add 3 d.a))
[b=4 c=5 d=6]
Here we're using %_
to add 3 to all of the values inside of our shell
variable a
.
/~zod/try=> =a [b='odors' c='twigs' d='tiles']
changed %a
/~zod/try=> %_(a b c.a, c d.a, d b.a)
[b='twigs' c='tiles' d='odors']
In this case we're using %_
to swap the values of the faces in a
.
/~zod/try=> =+ a=1
=+ z=|=(b=@ (add a b))
(z 1)
2
/~zod/try=> =+ a=1
=+ z=|=(b=@ (add a b))
(%_(z a 100) 1)
101
At first we set up a simple gate z
with a variable, a
in its
context. Subsequently we use %_
to change the value of a
within the
context of z
and compute the output again.