on beeb398 help sign in
52 lines 955 B history raw
1### `++mate`
3Choose
5Accepts two units `a` and `b` whose values are expected to be
6equivalent. If either is empty, then the value of the other is produced.
7If neither are empty, it asserts that both values are the same and
8produces that value. If the assertion fails, `++mate` crashes with
9`'mate'` in the stack trace.
11Accepts
12-------
14`a` is a unit.
16`b` is a unit.
18Produces
19--------
21A unit or crash.
23Source
24------
26 ++ mate :: choose
27 |* {a/(unit) b/(unit)}
28 ?~ b a
29 ?~ a b
30 ?.(=(u.a u.b) ~|('mate' !!) a)
33Examples
34--------
36 ~zod/try=> =a ((unit @) [~ 97])
37 ~zod/try=> =b ((unit @) [~ 97])
38 ~zod/try=> (mate a b)
39 [~ 97]
40 ~zod/try=> =a ((unit @) [~ 97])
41 ~zod/try=> =b ((unit @) [~])
42 ~zod/try=> (mate a b)
43 [~ 97]
44 ~zod/try=> =a ((unit @) [~ 97])
45 ~zod/try=> =b ((unit @) [~ 98])
46 ~zod/try=> (mate a b)
47 ! 'mate'
48 ! exit
52***