@@ -4,157 +4,151 @@ navhome: /docs/
6# 2n: functional hacks
6# 2n: functional hacks
7### `++cork`
8### `++cork`
9Build `f` such that `(f x) .= (b (a x))`.
12Build `f` such that `(f x) .= (b (a x))`.
11`a` is a noun.
16`a` is a noun.
13`b` is a gate.
18`b` is a gate.
18− ++ cork |*({a/_|=(* **) b/gate} (corl b a)) :: compose forward
22+ ++ cork |*([a=_|=(* **) b=gate] (corl b a))
21−Examples
24+#### Examples
24 > (:(cork dec dec dec) 20)
26 > (:(cork dec dec dec) 20)
26 > =mal (mo (limo a+15 b+23 ~))
29 > =mal (mo (limo a+15 b+23 ~))
27 > ((cork ~(got by mal) dec) %a)
30 > ((cork ~(got by mal) dec) %a)
29 > ((cork ~(got by mal) dec) %b)
33 > ((cork ~(got by mal) dec) %b)
35### `++corl`
38### `++corl`
37−Gate compose
40+Compose backward
39−XX Revisit
42+Build `f` such that
41`a` is a gate.
46`a` is a gate.
43`b` is a noun.
48`b` is a noun.
48− ++ corl :: compose backwards
52+ ++ corl
49− |* {a/gate b/_|=(* **)}
53+ |* [a=gate b=_|=(* **)]
50 =< +:|.((a (b))) :: span check
54 =< +:|.((a (b))) :: span check
51− |* c/_+<.b
55+ |* c=_+<.b
55−Examples
59+#### Examples
58 > ((corl (lift bex) (slat %ud)) '2')
61 > ((corl (lift bex) (slat %ud)) '2')
64### `++curr`
66### `++curr`
66Right curry
68Right curry
68−Right curry a gate, binding the tail of its sample
70+Right-curry a gate, binding the tail of its sample
70−Accepts
72+#### Accepts
73`a` is a gate.
74`a` is a gate.
75`c` is a noun.
76`c` is a noun.
77−Produces
78+#### Produces
84− ++ curr :: curry right
84+ ++ curr
85− |* {a/_|=(^ **) c/*}
85+ |* [a=_|=(^ **) c=*}
86− |* b/_+<+.a
86+ |* b=_+<+.a
90−Examples
89+#### Examples
93− > =tep (curr scan sym)
91+ > =tep (cury scan sym)
94 > `@t`(tep "asd")
92 > `@t`(tep "asd")
96 > `@t`(tep "lek-om")
95 > `@t`(tep "lek-om")
102### `++cury`
100### `++cury`
104Curry a gate, binding the head of its sample
104Curry a gate, binding the head of its sample
106−Accepts
106+#### Accepts
109`a` is a gate.
108`a` is a gate.
111`b` is a noun.
110`b` is a noun.
113−Produces
112+#### Produces
118−Source
116+#### Source
121− ++ cury :: curry left
118+ ++ cury
122− |* {a/_|=(^ **) b/*}
119+ |* [a=_|=(^ **) b=*}
123− |* c/_+<+.a
120+ |* c=_+<+.a
128−Examples
124+#### Examples
131 > =mol (cury add 2)
126 > =mol (cury add 2)
132 > (mol 4)
127 > (mol 4)
134 > (mol 7)
130 > (mol 7)
140### `++hard`
134### `++hard`
142Demands that a specific type be produced, crashing the program if it is
138Demands that a specific type be produced, crashing the program if it is
145−Source
141+#### Source
148− ++ hard :: force remold
143+ ++ hard
149− |* han/gate
144+ |* han=gate
150− |= fud/* ^- han
145+ |= fud=* ^- han
151 ~_ leaf+"hard"
146 ~_ leaf+"hard"
152 =+ gol=(han fud)
147 =+ gol=(han fud)
153 ?>(=(gol fud) gol)
148 ?>(=(gol fud) gol)
156−Examples
151+#### Examples
159 > ((hard (list)) (limo [1 2 3 ~]))
153 > ((hard (list)) (limo [1 2 3 ~]))
@@ -171,21 +165,21 @@ Examples
172### `++soft`
166### `++soft`
174Politely requests a specific type to be produced, producing null if it
170Politely requests a specific type to be produced, producing null if it
177−Source
173+#### Source
180− ++ soft :: maybe remold
175+ ++ soft
181− |* han/gate
176+ |* han=gate
182− |= fud/* ^- (unit han)
177+ |= fud=* ^- (unit han)
183 =+ gol=(han fud)
178 =+ gol=(han fud)
184 ?.(=(gol fud) ~ [~ gol])
179 ?.(=(gol fud) ~ [~ gol])
187−Examples
182+#### Examples
190 > ((soft %4) (add 2 2))
184 > ((soft %4) (add 2 2))
@@ -200,4 +194,194 @@ Examples
202+Produces the head of a cell.
233+Produces the same value that it was given.
263+Produces a stack trace if the stack trace isn't null, then produces the other
279+ ?~(a same ~>(%slog.[pri i.a] $(a t.a)))
283+ > =+ result=((slog [%leaf "error-message"]~) [12 13]) [%product result]
288+`slog` is intended to be put in the middle of a bunch of chained function
289+calls that string a piece of data through them, so that an error message will be
290+printed if there's one to print.
297+Ends the program and produces a `tang` tracing error message.
317+ > ~>(%mean.[%leaf "fuse-loop"] !!)
326+Produces the tail of a cell.
357+Checks if `a` and `b` are equal, producing a flag.
371+ ++ test |=(^ =(+<- +<+))
381+ > (test "hello" 'hello')
384+ > (test "hello" ['h' 'e' 'l' 'l' 'o' ~])