2title = "2a: Unit Logic"
11Applies a function `b` that produces a unit to the unwrapped value of ++unit
12`a` (`u.a`). If `a` is empty, `~` is produced.
18`b` is a function that accepts a noun and produces a unit.
28 |* [a=(unit) b=$-(* (unit))]
36 > (biff (some 5) |=(a=@ (some (add a 2))))
39 > (biff ~ |=(a=@ (some (add a 2))))
47Non-unit function to unit, producing unit
49Applies a function `b` to the value (`u.a`) of a ++unit `a`, producing
50a unit. Used when you want a function that does not accept or produce a
51unit to both accept and produce a unit.
76 > (bind ((unit @) [~ 97]) ,@t)
79 > =a |=(a=@ (add a 1))
80 > (bind ((unit @) [~ 2]) a)
90Replaces an empty ++unit `b` with the product of a called trap
91`a`. If the unit is not empty, then the original unit is produced.
101Either the product of `a` or the value inside of unit `b`.
118 > ((bond |.((bex 10))) ~)
121 > ((bond |.((bex 10))) (slaw %ud '123'))
129Group unit values into pair
131Produces `~` if either `a` or `b` are empty. Otherwise, produces a
132++unit whose value is a cell of the values of two input units `a` and
143A unit of the two initial values.
149 |* [a=(unit) b=(unit)]
158 > (both (some 1) (some %b))
168Apply function to two units
170Applies a binary function `c`--which does not usually accept or produce a
171`++unit`-- to the values of two units, `a` and `b`, producing a unit.
179`c` is a function that performs a binary operation.
189 |* [a=(unit) b=(unit) c=_|=(^ +<-)]
198 > =u ((unit @t) [~ 'a'])
199 > =v ((unit @t) [~ 'b'])
200 > (clap u v |=([a=@t b=@t] (welp (trip a) (trip b))))
203 > =a ((unit @u) [~ 1])
204 > =b ((unit @u) [~ 2])
205 > =c |=([a=@ b=@] (add a b))
217Makes a ++list of the unwrapped value (`u.a`) of a `++unit` `a`.
239 > =a ((unit @) [~ 97])
252Give unit a default value
254Produces a default value `b` for a `++unit` `a` in cases where `a` is null.
260`b` is a noun that's used as the default value.
264Either a noun `b` or the unwrapped value of unit `a`.
288Accepts a `++gate` `a` and produces a function that accepts `++unit`
289`b` to which it applies `a`. Used when you want a function that does not accept
290or produce a unit to both accept and produce a unit.
305 ++ lift :: lift gate (fmap)
307 |* b=(unit) :: curried
314 > ((lift dec) `(unit @)`~)
317 > ((lift dec) `(unit @)`[~ 20])
327Accepts two units `a` and `b` whose values are expected to be
328equivalent. If either is empty, then the value of the other is produced.
329If neither are empty, it asserts that both values are the same and
330produces that value. If the assertion fails, `++mate` crashes with
331`'mate'` in the stack trace.
347 |* [a=(unit) b=(unit)]
350 ?.(=(u.a u.b) ~|('mate' !!) a)
356 > =a ((unit @) [~ 97])
357 > =b ((unit @) [~ 97])
361 > =a ((unit @) [~ 97])
366 > =a ((unit @) [~ 97])
367 > =b ((unit @) [~ 98])
379Retrieve the value from a `++unit` and crash if the unit is null.
387Either the unwrapped value of `a` (`u.a`), or crash.
401 > =a ((unit [@t @t]) [~ ['a' 'b']])
405 > =a ((unit @ud) [~ 17])
420Takes any noun `a` and produces a `++unit` with the value set to `a`.
433 ++ some :: lift (pure)
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