urbit/base/pub/doc/hoon/runes/cn/cnls.md
2015-04-29 18:48:45 -04:00

1015 B

cenlus, %+, %cnls

Slam, two arguments

%+ is a synthetic rune that that pulls [$] from the door p with its sample set to [%cntr q r]. %+ in the most common case simply slams p with q and r, similar to a function call with two arguments.

Produces

Twig: [%cnls p=twig q=twig r=twig]

Sample

p is a twig, most commonly a gate. q and r are twigs.

Tall form

%+  p
  q
r

Wide form

%+(p q r)

Irregular form

None

Examples

/~zod/try=> =a  |=  [b=@ c=@]
    (add b c)
new var %a
/~zod/try=> %+  a
              2
            1
3
/~zod/try=> %+(a 2 3)
5

First we set a shell variable a to be a gate that takes two arguments and produces their sum. Then we use %+ to pass values to our gate. %+ is most useful for code organization, when you need to compute intermediate products for your final computation.