2title = "2a: Unit Logic"
10Applies a function `b` that produces a unit to the unwrapped value of ++unit
11`a` (`u.a`). If `a` is empty, `~` is produced.
17`b` is a function that accepts a noun and produces a unit.
27 |* [a](unit) b]$-(* (unit))]
35 > (biff (some 5) |=(a]@ (some (add a 2))))
38 > (biff ~ |=(a]@ (some (add a 2))))
46Non-unit function to unit, producing unit
48Applies a function `b` to the value (`u.a`) of a ++unit `a`, producing
49a unit. Used when you want a function that does not accept or produce a
50unit to both accept and produce a unit.
75 > (bind ((unit @) [~ 97]) ,@t)
78 > =a |=(a]@ (add a 1))
79 > (bind ((unit @) [~ 2]) a)
89Replaces an empty ++unit `b` with the product of a called trap
90`a`. If the unit is not empty, then the original unit is produced.
100Either the product of `a` or the value inside of unit `b`.
117 > ((bond |.((bex 10))) ~)
120 > ((bond |.((bex 10))) (slaw %ud '123'))
128Group unit values into pair
130Produces `~` if either `a` or `b` are empty. Otherwise, produces a
131++unit whose value is a cell of the values of two input units `a` and
142A unit of the two initial values.
148 |* [a=(unit) b=(unit)]
157 > (both (some 1) (some %b))
167Apply function to two units
169Applies a binary function `c`--which does not usually accept or produce a
170`++unit`-- to the values of two units, `a` and `b`, producing a unit.
178`c` is a function that performs a binary operation.
188 |* [a](unit) b=(unit) c=_|=(^ +<-)]
197 > =u ((unit @t) [~ 'a'])
198 > =v ((unit @t) [~ 'b'])
199 > (clap u v |=([a=@t b=@t] (welp (trip a) (trip b))))
202 > =a ((unit @u) [~ 1])
203 > =b ((unit @u) [~ 2])
204 > =c |=([a=@ b=@] (add a b))
216Makes a ++list of the unwrapped value (`u.a`) of a `++unit` `a`.
238 > =a ((unit @) [~ 97])
251Give unit a default value
253Produces a default value `b` for a `++unit` `a` in cases where `a` is null.
259`b` is a noun that's used as the default value.
263Either a noun `b` or the unwrapped value of unit `a`.
287Accepts a `++gate` `a` and produces a function that accepts `++unit`
288`b` to which it applies `a`. Used when you want a function that does not accept
289or produce a unit to both accept and produce a unit.
304 ++ lift :: lift gate (fmap)
306 |* b=(unit) :: curried
313 > ((lift dec) `(unit @)`~)
316 > ((lift dec) `(unit @)`[~ 20])
326Accepts two units `a` and `b` whose values are expected to be
327equivalent. If either is empty, then the value of the other is produced.
328If neither are empty, it asserts that both values are the same and
329produces that value. If the assertion fails, `++mate` crashes with
330`'mate'` in the stack trace.
346 |* [a=(unit) b=(unit)]
349 ?.(=(u.a u.b) ~|('mate' !!) a)
355 > =a ((unit @) [~ 97])
356 > =b ((unit @) [~ 97])
360 > =a ((unit @) [~ 97])
365 > =a ((unit @) [~ 97])
366 > =b ((unit @) [~ 98])
378Retrieve the value from a `++unit` and crash if the unit is null.
386Either the unwrapped value of `a` (`u.a`), or crash.
400 > =a ((unit [@t @t]) [~ ['a' 'b']])
404 > =a ((unit @ud) [~ 17])
419Takes any atom `a` and produces a `++unit` with the value set to `a`.
432 ++ 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