2a: Unit Logic
+biff
+biffA +unit as argument.
Applies a $gate .b that produces a +unit to the unwrapped value of +unit .a (.u.a). If .a is empty, ~ is produced.
Accepts
.a is a +unit.
.b is a $gate that accepts a $noun and produces a +unit.
Produces
A +unit.
Source
++ biff
|* [a=(unit) b=$-(* (unit))]
?~ a ~
(b u.a)Examples
> (biff (some 5) |=(a=@ (some (add a 2))))
[~ u=7]+bind
+bindNon-unit $gate to +unit, producing +unit.
Applies a $gate .b to the value (.u.a) of a +unit .a, producing a +unit. Used when you want a $gate that does not accept or produce a +unit to both accept and produce a +unit.
Accepts
.a is a +unit.
.b is a gate.
Produces
A +unit.
Source
Examples
+bond
+bondReplace null.
Replaces an empty +unit .b with the product of a called +trap .a. If the +unit is not empty, then the original +unit is produced.
Accepts
.a is a +trap.
.b is a +unit.
Produces
Either the product of .a or the value inside of +unit .b.
Source
Examples
+both
+bothGroup +unit values into pair.
Produces ~ if either .a or .b are empty. Otherwise, produces a +unit whose value is a cell of the values of two input +units .a and .b.
Accepts
.a is a +unit.
.b is a +unit.
Produces
A +unit of the two initial values.
Source
Examples
+clap
+clapCombine two +units with a gate.
Applies a binary $gate .c (which does not usually accept or produce a +unit) to the values of two +units, .a and .b, producing a +unit.
If .a is null, produces .b. If .b is null, produces .a. Otherwise, produces the product of .c in a +unit.
Accepts
.a is a +unit.
.b is a +unit.
.c is a $gate that performs a binary operation.
Produces
A +unit.
Source
Examples
+clef
+clefCompose two +units with a gate.
Applies a binary $gate .c (which does not usually accept +units) to the values of two +units, .a and .b, producing a +unit.
If .a or .b are null, produces null. Otherwise, produces the produce of .c.
Accepts
.a is a +unit.
.b is a +unit.
.c is a $gate that takes a +cell and produces a +unit.
Produces
A +unit.
Source
Examples
+drop
+dropConvert a +unit to a list.
Makes a +list of the unwrapped value (.u.a) of a +unit .a.
Accepts
.a is a +unit.
Produces
A list.
Source
Examples
+fall
+fallGive +unit a default value.
Produces a default value .b for a +unit .a in cases where .a is null.
Accepts
.a is a +unit.
.b is a $noun that's used as the default value.
Produces
Either a $noun .b or the unwrapped value of +unit .a.
Source
Examples
+flit
+flitMake filter.
Accepts $gate .a which produces a $flag. Applies .a to .b, producing .b wrapped in a +unit if true, otherwise produces null.
+flit is a wet $gate that takes .a and produces a new wet $gate that takes .b.
Accepts
.a is a $gate which produces a $flag, and is the sample of the outer wet gate.
.b is any $noun, and is the sample of the inner wet gate.
Produces
A (unit [type]), where [type] is the type of .b.
Source
Examples
+hunt
+huntFirst of units.
Apply binary $gate .ord, which produces a $flag, to units .a and .b. Produce .a if true and .b if false. If .a is null, produce .b. If .b is null, produce .a.
This allows selecting between two units by some rule.
Accepts
.ord is a $-(^ ?) - a binary $gate that produces a $flag.
.a is a +unit.
.b is a +unit.
Produces
A +unit.
Source
Examples
+lift
+liftCurried bind.
Accepts $gate .a and produces a $gate that accepts +unit .b to which it applies .a. Used when you want a $gate that does not accept or produce a +unit to both accept and produce a +unit.
Accepts
.a is a $mold.
.b is a +unit.
Produces
A +unit.
Source
Examples
+mate
+mateChoose.
Accepts two +units .a and .b whose values are expected to be equivalent. If either is empty, then the value of the other is produced. If neither are empty, it asserts that both values are the same and produces that value. If the assertion fails, +mate crashes with 'mate' in the stack trace.
Accepts
.a is a +unit.
.b is a +unit.
Produces
A +unit or crash.
Source
Examples
+need
+needUnwrap +unit.
Retrieve the value from a +unit and crash if the +unit is null.
Accepts
.a is a +unit.
Produces
Either the unwrapped value of .a (.u.a), or crash.
Source
Examples
+some
+someWrap value in a +unit.
Takes any $noun .a and produces a +unit with the value set to .a.
Accepts
.a is a $noun.
Produces
A +unit.
Source
Examples
Last updated