1# `:dip`, `;~`, "semsig" `{$dip p/twig q/(list twig)}`
5Composes a list of functions `p` and `q` under a monad. `q` can be 1 or more functions.
7Regular form: 1-fixed, `q` is *running*
11 ~zod/try=> =cmp |=([a=tape b=$+(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
12 ~zod/try=> ;~(cmp trip)
13 <1.xef [a=@ <374.hzt 100.kzl 1.ypj %164>]>
14 ~zod/try=> (;~(cmp trip) 'a')
17`;~` accepts a composer and a nonempty list of functions; at one gate, the
18composer is ignored, and the gate applied directly.
20 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a])) 'a')
22 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a])) '')
25For multiple gates, `;~` uses the composer to connect the gates in
28 ~zod/try=> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
30 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
32 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
34 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
36 ~zod/try=> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
39Multiple gates are equivalent to stacked semsigs.
41------------------------------------------------------------------------
44 ~zod/try=> ((slat %p) '~nec')
46 ~zod/try=> ((slat %p) 'nec')
48 ~zod/try=> ;~(biff (slat %p))
49 <1.ags [txt=@ta <1.wqj [mod=@tas <374.hzt 100.kzl 1.ypj %164>]>]>
50 ~zod/try=> (;~(biff (slat %p)) '~zod')
52 ~zod/try=> (;~(biff (slat %p)) '~')
54 ~zod/try=> (;~(biff (slat %p)) '~nec')
57More commonly, this can be used for unit composition. `(slat %p)` parses
58cords in phonetic base, failure case: invalid text
60 ~zod/try=> (mo [~nec 12] [~tug 16] ~)
61 {[p=~nec q=12] [p=~tug q=16]}
62 ~zod/try=> ~(get by (mo [~nec 12] [~tug 16] ~))
63 <1.yvn [* <18.wzi [a=nlr([p=@p q=@ud]) <374.hzt 100.kzl 1.ypj %164>]>]>
64 ~zod/try=> =yaz ~(get by (mo [~nec 12] [~tug 16] ~))
72`mo` makes a map, and `+-get`:by is used to retrieve values from one,
73failure case: no such key
75 ~zod/try=> (;~(biff (slat %p) yaz) '~zod')
77 ~zod/try=> (;~(biff (slat %p) yaz) '~nec')
79 ~zod/try=> (;~(biff (slat %p) yaz) 'tug')
81 ~zod/try=> (;~(biff (slat %p) yaz) '~tug')
84 ~zod/try=> (;~(biff (slat %p) yaz |=(a=@ud [~ (add 100 a)])) '~nec')
86 ~zod/try=> (;~(biff (slat %p) yaz |=(a=@ud [~ (add 100 a)])) '~zod')
88 ~zod/try=> (;~(biff (slat %p) yaz |=(a=@ud [~ (add 100 a)])) 'mal')
91These can be combined with `biff`, which connects a previous succeeded
92unit result by a gate that itself produces a unit from it.
94------------------------------------------------------------------------
96 ~zod/try=> (hep [1 1] "")
98 ~zod/try=> (hep [1 1] "-")
99 [p=[p=1 q=2] q=[~ [p=~~- q=[p=[p=1 q=2] q=""]]]]
100 ~zod/try=> `(like cord)`(hep [1 1] "-")
101 [p=[p=1 q=2] q=[~ [p='-' q=[p=[p=1 q=2] q=""]]]]
102 ~zod/try=> `(like cord)`(hep [1 1] "?")
104 ~zod/try=> (lus [1 1] "+")
105 [p=[p=1 q=2] q=[~ [p=~~~2b. q=[p=[p=1 q=2] q=""]]]]
106 ~zod/try=> `(like cord)`(lus [1 1] "+")
107 [p=[p=1 q=2] q=[~ [p='+' q=[p=[p=1 q=2] q=""]]]]
108 ~zod/try=> `(like cord)`(lus [1 1] "++")
109 [p=[p=1 q=2] q=[~ [p='+' q=[p=[p=1 q=2] q="+"]]]]
110 ~zod/try=> `(like cord)`(lus [1 1] " +")
112 ~zod/try=> `(like cord)`(;~(pose hep lus) [1 1] "?")
114 ~zod/try=> `(like cord)`(;~(pose hep lus) [1 1] "-")
115 [p=[p=1 q=2] q=[~ [p='-' q=[p=[p=1 q=2] q=""]]]]
116 ~zod/try=> `(like cord)`(;~(pose hep lus) [1 1] "+")
117 [p=[p=1 q=2] q=[~ [p='+' q=[p=[p=1 q=2] q=""]]]]
118 ~zod/try=> `(like cord)`(;~(pose hep lus) [1 1] "a")
120 ~zod/try=> `(like cord)`(;~(pose hep lus) [1 1] "-+")
121 [p=[p=1 q=2] q=[~ [p='-' q=[p=[p=1 q=2] q="+"]]]]
122 ~zod/try=> `(like ,[cord cord])`(;~(plug hep lus) [1 1] "+")
124 ~zod/try=> `(like ,[cord cord])`(;~(plug hep lus) [1 1] "-+")
125 [p=[p=1 q=3] q=[~ [p=['-' '+'] q=[p=[p=1 q=3] q=""]]]]
126 ~zod/try=> `(like ,[cord cord])`(;~(plug hep lus) [1 1] "-+ ")
127 [p=[p=1 q=3] q=[~ [p=['-' '+'] q=[p=[p=1 q=3] q=" "]]]]
129Most prominently, however, `;~` is used for combinator parsers,
130composing [rule]s in various ways
132See parsing sections 2eA - 2eH, and specifically section 2eD, for more
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