on master help sign in
Merge pull request #415 from jfranklin9000/library-4i

moved some arm documentation from 4k to 4i to match hoon.hoon

commit9ed41bb41346ecf75b8f84e8181c7d6ce46607ba authorrmariani <robert@tlon.io> dateMon 4 Mar 2019, 13:17 (8 years ago) parent3bb57fddb20f25
2 files changed+1048−1049
reference/library/4i.udon+1048−1 reference/library/4k.udon−1048
reference/library/4i.udon+1048−1
@@ -7,4 +7,1051 @@
77
88# 4i: parsing (useful idioms)
99
10−(To be documented)
10+### `++alf`
11+
12+Alphabetic characters
13+
14+Parse alphabetic characters, both upper and lowercase.
15+
16+#### Source
17+
18+```
19+ ++ alf ;~(pose low hig) :: alphabetic
20+```
21+
22+#### Examples
23+
24+```
25+ > (scan "a" alf)
26+ ~~a
27+
28+ > (scan "A" alf)
29+ ~~~41.
30+
31+ > (scan "AaBbCc" (star alf))
32+ "AaBbCc"
33+```
34+
35+
36+---
37+### `++aln`
38+
39+Alphanumeric characters
40+
41+Parse alphanumeric characters - both alphabetic characters and numbers.
42+
43+#### Source
44+
45+```
46+ ++ aln ;~(pose low hig nud) :: alphanumeric
47+```
48+
49+#### Examples
50+
51+```
52+ > (scan "0" aln)
53+ ~~0
54+
55+ > (scan "alf42" (star aln))
56+ "alf42"
57+
58+ > (scan "0123456789abcdef" (star aln))
59+ "0123456789abcdef"
60+```
61+
62+
63+---
64+### `++alp`
65+
66+Alphanumeric and `-`
67+
68+Parse alphanumeric strings and hep, "-".
69+
70+#### Source
71+
72+```
73+ ++ alp ;~(pose low hig nud hep) :: alphanumeric and -
74+```
75+
76+#### Examples
77+
78+```
79+ > (scan "7" alp)
80+ ~~7
81+
82+ > (scan "s" alp)
83+ ~~s
84+
85+ > (scan "123abc-" (star alp))
86+ "123abc-"
87+```
88+
89+
90+---
91+
92+### `++bet`
93+
94+Axis syntax `-`, `+`
95+
96+Parse the hep and lus axis syntax.
97+
98+#### Source
99+
100+```
101+ ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - +
102+```
103+
104+#### Examples
105+
106+```
107+ > (scan "-" bet)
108+ 2
109+
110+ > (scan "+" bet)
111+ 3
112+```
113+
114+
115+---
116+### `++bin`
117+
118+Binary to atom
119+
120+Parse a tape of binary (0s and 1s) and produce its atomic representation.
121+
122+#### Source
123+
124+```
125+ ++ bin (bass 2 (most gon but)) :: binary to atom
126+```
127+
128+#### Examples
129+
130+```
131+ > (scan "0000" bin)
132+ 0
133+
134+ > (scan "0001" bin)
135+ 1
136+
137+ > (scan "0010" bin)
138+ 2
139+
140+ > (scan "100000001111" bin)
141+ 2.063
142+```
143+
144+
145+---
146+### `++but`
147+
148+Binary digit
149+
150+Parse a single binary digit.
151+
152+#### Source
153+
154+```
155+ ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit
156+```
157+
158+#### Examples
159+
160+```
161+ > (scan "0" but)
162+ 0
163+ > (scan "1" but)
164+ 1
165+ > (scan "01" but)
166+ ! {1 2}
167+ ! 'syntax-error'
168+ ! exit
169+ > (scan "01" (star but))
170+ ~[0 1]
171+```
172+
173+
174+---
175+### `++cit`
176+
177+Octal digit
178+
179+Parse a single octal digit.
180+
181+#### Source
182+
183+```
184+ ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit
185+```
186+
187+#### Examples
188+
189+```
190+ > (scan "1" cit)
191+ 1
192+ > (scan "7" cit)
193+ 7
194+ > (scan "8" cit)
195+ ! {1 1}
196+ ! 'syntax-error'
197+ ! exit
198+ > (scan "60" (star cit))
199+ ~[6 0]
200+```
201+
202+
203+---
204+### `++dem`
205+
206+Decimal to atom
207+
208+Parse a decimal number to an atom.
209+
210+#### Source
211+
212+```
213+ ++ dem (bass 10 (most gon dit)) :: decimal to atom
214+```
215+
216+#### Examples
217+
218+```
219+ > (scan "7" dem)
220+ 7
221+ > (scan "42" dem)
222+ 42
223+ > (scan "150000000" dem)
224+ 150.000.000
225+ > (scan "12456" dem)
226+ 12.456
227+```
228+
229+
230+---
231+### `++dit`
232+
233+Decimal digit
234+
235+Parse a single decimal digit.
236+
237+#### Source
238+
239+```
240+ ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit
241+```
242+
243+#### Examples
244+
245+```
246+ > (scan "7" dit)
247+ 7
248+ > (scan "42" (star dit))
249+ ~[4 2]
250+ > (scan "26000" (star dit))
251+ ~[2 6 0 0 0]
252+```
253+
254+
255+---
256+### `++dog`
257+
258+`.` optional gap
259+
260+Dot followed by an optional gap, used with numbers.
261+
262+#### Source
263+
264+```
265+ ++ dog ;~(plug dot gay) ::
266+```
267+
268+#### Examples
269+
270+```
271+ > 1.234.703
272+ 703
273+ 1.234.703
274+
275+ > (scan "a. " ;~(pfix alf dog))
276+ [~~~. ~]
277+```
278+
279+
280+---
281+### `++doh`
282+
283+`@p` separator
284+
285+Phonetic base phrase separator
286+
287+#### Source
288+
289+```
290+ ++ doh ;~(plug ;~(plug hep hep) gay) ::
291+```
292+
293+#### Examples
294+
295+```
296+ /> ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
297+ ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
298+ /> ~nopfel-botduc-nilnev-dolfyn--
299+ haspub-natlun-lodmur-holtyd
300+ ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
301+ > (scan "--" doh)
302+ [[~~- ~~-] ~]
303+ > (scan "-- " doh)
304+ [[~~- ~~-] ~]
305+```
306+
307+
308+---
309+### `++dun`
310+
311+`--` to `~`
312+
313+Parse phep, `--`, to null, `~`.
314+
315+#### Source
316+
317+```
318+ ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~
319+```
320+
321+#### Examples
322+
323+```
324+ > (scan "--" dun)
325+ ~
326+ > (dun [[1 1] "--"])
327+ [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=""]]]]
328+```
329+
330+
331+---
332+
333+### `++duz`
334+
335+`==` to `~`
336+
337+Parse stet, `==`, to null `~`.
338+
339+#### Source
340+
341+```
342+ ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
343+```
344+
345+#### Examples
346+
347+```
348+ > (scan "==" duz)
349+ ~
350+ > (duz [[1 1] "== |=..."])
351+ [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=" |=..."]]]]
352+```
353+
354+
355+---
356+
357+### `++gah`
358+
359+Newline or ' '
360+
361+Whitespace component, either newline or space.
362+
363+#### Source
364+
365+```
366+ ++ gah (mask [`@`10 ' ' ~]) :: newline or ace
367+```
368+
369+#### Examples
370+
371+```
372+ /> ^- * :: show spaces
373+ """
374+ -
375+ -
376+ -
377+ """
378+ [32 32 32 45 10 32 45 10 32 32 45 0]
379+ /> ^- *
380+ """
381+
382+ """
383+ [32 32 32 10 32 10 32 32 0]
384+ /> ^- (list ,@)
385+ %- scan :_ (star gah)
386+ """
387+
388+ """
389+ ~[32 32 32 10 32 10 32 32]
390+```
391+
392+
393+---
394+### `++gap`
395+
396+Plural whitespace
397+
398+Separates tall runes
399+
400+#### Source
401+
402+```
403+ ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) :: plural whitespace
404+```
405+
406+
407+---
408+### `++gaq`
409+
410+End of line
411+
412+Two spaces, a newline, or comment.
413+
414+#### Source
415+
416+```
417+ ++ gaq ;~ pose :: end of line
418+ (just `@`10)
419+ ;~(plug gah ;~(pose gah vul))
420+ vul
421+ ==
422+```
423+
424+
425+
426+---
427+### `++gaw`
428+
429+Classic whitespace
430+
431+Terran whitespace.
432+
433+#### Source
434+
435+```
436+ ++ gaw (cold ~ (star ;~(pose vul gah))) :: classic white
437+```
438+
439+
440+---
441+### `++gay`
442+
443+Optional gap
444+
445+Optional gap.
446+
447+#### Source
448+
449+```
450+ ++ gay ;~(pose gap (easy ~)) ::
451+```
452+
453+---
454+### `++gon`
455+
456+Long numbers
457+
458+Parse long numbers - Numbers which wrap around the shell with the line
459+
460+#### Source
461+
462+```
463+ ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ /
464+```
465+
466+#### Examples
467+
468+```
469+ > (scan "\\/" gon)
470+ [~~~5c. ~ ~~~2f.]
471+
472+ > (gon [[1 1] "\\/"])
473+ [p=[p=1 q=3] q=[~ u=[p=[~~~5c. ~ ~~~2f.] q=[p=[p=1 q=3] q=""]]]]
474+```
475+
476+
477+---
478+### `++gul`
479+
480+Axis syntax `<` or `>`
481+
482+Parse the axis gal and gar axis syntax.
483+
484+#### Source
485+
486+```
487+ ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < >
488+```
489+
490+#### Examples
491+
492+```
493+ > (scan "<" gul)
494+ 2
495+
496+ > (scan ">" gul)
497+ 3
498+```
499+
500+
501+---
502+### `++hex`
503+
504+Hex to atom
505+
506+Parse any hexadecimal number to an atom.
507+
508+#### Source
509+
510+```
511+ ++ hex (bass 16 (most gon hit)) :: hex to atom
512+```
513+
514+#### Examples
515+
516+```
517+ > (scan "a" hex)
518+ 10
519+ > (scan "A" hex)
520+ 10
521+ > (scan "2A" hex)
522+ 42
523+ > (scan "1ee7" hex)
524+ 7.911
525+ > (scan "1EE7" hex)
526+ 7.911
527+ > (scan "1EE7F7" hex)
528+ 2.025.463
529+ > `@ux`(scan "1EE7F7" hex)
530+ 0x1e.e7f7
531+```
532+
533+---
534+### `++hig`
535+
536+Uppercase
537+
538+Parse a single uppercase letter.
539+
540+#### Source
541+
542+```
543+ ++ hig (shim 'A' 'Z') :: uppercase
544+```
545+
546+#### Examples
547+
548+```
549+ > (scan "G" hig)
550+ ~~~47.
551+
552+ > `cord`(scan "G" hig)
553+ 'G'
554+
555+ > (scan "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (star hig))
556+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
557+
558+ > (hig [[1 1] "G"])
559+ [p=[p=1 q=2] q=[~ [p=~~~47. q=[p=[p=1 q=2] q=""]]]]
560+```
561+
562+
563+---
564+### `++hit`
565+
566+Hex digits
567+
568+Parse a single hexadecimal digit.
569+
570+#### Source
571+
572+```
573+ ++ hit ;~ pose :: hex digits
574+ dit
575+ (cook |=(a=char (sub a 87)) (shim 'a' 'f'))
576+ (cook |=(a=char (sub a 55)) (shim 'A' 'F'))
577+ ==
578+```
579+
580+#### Examples
581+
582+```
583+ > (scan "a" hit)
584+ 10
585+ > (scan "A" hit)
586+ 10
587+ > (hit [[1 1] "a"])
588+ [p=[p=1 q=2] q=[~ [p=10 q=[p=[p=1 q=2] q=""]]]]
589+ > (scan "2A" (star hit))
590+ ~[2 10]
591+```
592+
593+---
594+### `++iny`
595+
596+Indentation block
597+
598+Apply `++rule` to indented block starting at current column number, omitting
599+the leading whitespace.
600+
601+#### Accepts
602+
603+`sef` is a `++rule`
604+
605+#### Produces
606+
607+A `++rule`.
608+
609+#### Source
610+
611+```
612+ ++ inde |* sef/rule :: indentation block
613+ |= nail ^+ (sef)
614+ =+ [har tap]=[p q]:+<
615+ =+ lev=(fil 3 (dec q.har) ' ')
616+ =+ eol=(just `@t`10)
617+ =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap)
618+ ;~(simu ;~(plug eol eol) eol)
619+ ?~ q.roq roq
620+ =+ vex=(sef har(q 1) p.u.q.roq)
621+ =+ fur=p.vex(q (add (dec q.har) q.p.vex))
622+ ?~ q.vex vex(p fur)
623+ =- vex(p fur, u.q -)
624+ :+ &3.vex
625+ &4.vex(q.p (add (dec q.har) q.p.&4.vex))
626+ =+ res=|4.vex
627+ |- ?~ res |4.roq
628+ ?. =(10 -.res) [-.res $(res +.res)]
629+ (welp [`@t`10 (trip lev)] $(res +.res))
630+ ::
631+```
632+
633+#### Examples
634+
635+```
636+ > (scan "abc" (iny (star ;~(pose prn (just `@`10)))))
637+ "abc"
638+ > (scan "abc" (star ;~(pose prn (just `@`10))))
639+ "abc"
640+ > (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10)))))
641+ "abc
642+ de"
643+ > (scan " abc\0ade" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
644+ ! {1 6}
645+ ! exit
646+ > (scan " abc\0a de" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
647+ "abc
648+ de"
649+```
650+
651+
652+---
653+### `++low`
654+
655+Lowercase
656+
657+Parse a single lowercase letter.
658+
659+#### Source
660+
661+```
662+ ++ low (shim 'a' 'z') :: lowercase
663+```
664+
665+#### Examples
666+
667+```
668+ > (scan "g" low)
669+ ~~g
670+ > `cord`(scan "g" low)
671+ 'g'
672+ > (scan "abcdefghijklmnopqrstuvwxyz" (star low))
673+ "abcdefghijklmnopqrstuvwxyz"
674+ > (low [[1 1] "g"])
675+ [p=[p=1 q=2] q=[~ [p=~~g q=[p=[p=1 q=2] q=""]]]]
676+```
677+
678+
679+---
680+### `++mes`
681+
682+Hexbyte
683+
684+Parse a hexbyte.
685+
686+#### Source
687+
688+```
689+ ++ mes %+ cook :: hexbyte
690+ |=({a/@ b/@} (add (mul 16 a) b))
691+ ;~(plug hit hit)
692+```
693+
694+#### Examples
695+
696+```
697+ > (scan "2A" mes)
698+ 42
699+ > (mes [[1 1] "2A"])
700+ [p=[p=1 q=3] q=[~ u=[p=42 q=[p=[p=1 q=3] q=""]]]]
701+ > (scan "42" mes)
702+ 66
703+```
704+
705+
706+---
707+### `++nix`
708+
709+Letters and `-`
710+
711+Parse Letters and `-`.
712+
713+#### Source
714+
715+```
716+ ++ nix (boss 256 (star ;~(pose aln cab))) ::
717+```
718+
719+#### Examples
720+
721+```
722+ > (scan "as_me" nix)
723+ q=435.626.668.897
724+
725+ > `@t`(scan "as_me" nix)
726+ 'as_me'
727+```
728+
729+
730+---
731+
732+### `++nud`
733+
734+Numeric
735+
736+Parse a numeric character - A number.
737+
738+#### Source
739+
740+```
741+ ++ nud (shim '0' '9') :: numeric
742+```
743+
744+#### Examples
745+
746+```
747+ > (scan "0" nud)
748+ ~~0
749+ > (scan "7" nud)
750+ ~~7
751+ > (nud [[1 1] "1"])
752+ [p=[p=1 q=2] q=[~ [p=~~1 q=[p=[p=1 q=2] q=""]]]]
753+ > (scan "0123456789" (star nud))
754+ "0123456789"
755+```
756+
757+---
758+### `++prn`
759+
760+Printable character
761+
762+Parse any printable character.
763+
764+#### Source
765+
766+```
767+ ++ prn ;~(less (just `@`127) (shim 32 256))
768+```
769+
770+#### Examples
771+
772+```
773+ > (scan "h" prn)
774+ ~~h
775+ > (scan "!" prn)
776+ ~~~21.
777+ > (scan "\01" prn)
778+ ! {1 1}
779+ ! exit
780+```
781+
782+
783+---
784+### `++qit`
785+
786+Chars in cord
787+
788+Parse an individual character to its cord atom representation.
789+
790+#### Source
791+
792+```
793+ ++ qit ;~ pose :: chars in a cord
794+ ;~(less bas soq prn)
795+ ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
796+ ==
797+```
798+
799+#### Examples
800+
801+```
802+ > (scan "%" qit)
803+ 37
804+ > `@t`(scan "%" qit)
805+ '%'
806+ > (scan "0" qit)
807+ 48
808+ > (scan "E" qit)
809+ 69
810+ > (scan "a" qit)
811+ 97
812+ > (scan "\\0a" qit)
813+ 10
814+ > `@ux`(scan "\\0a" qit)
815+ 0xa
816+ > (scan "cord" (star qit))
817+ ~[99 111 114 100]
818+```
819+
820+
821+---
822+### `++qit`
823+
824+Chars in cord
825+
826+Parse an individual character to its cord atom representation.
827+
828+#### Source
829+
830+```
831+ ++ qit ;~ pose :: chars in a cord
832+ ;~(less bas soq prn)
833+ ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
834+ ==
835+```
836+
837+#### Examples
838+
839+```
840+ > (scan "%" qit)
841+ 37
842+ > `@t`(scan "%" qit)
843+ '%'
844+ > (scan "0" qit)
845+ 48
846+ > (scan "E" qit)
847+ 69
848+ > (scan "a" qit)
849+ 97
850+ > (scan "\\0a" qit)
851+ 10
852+ > `@ux`(scan "\\0a" qit)
853+ 0xa
854+ > (scan "cord" (star qit))
855+ ~[99 111 114 100]
856+```
857+
858+
859+
860+---
861+### `++qut`
862+
863+Cord
864+
865+Parse single-soq cord with `\{gap}/` anywhere in the middle, or triple-single
866+quote (aka triple-soq) cord, between which must be in an indented block.
867+
868+#### Source
869+
870+```
871+ ++ qut ;~ pose :: cord
872+ ;~ less soqs
873+ (ifix [soq soq] (boss 256 (more gon qit)))
874+ ==
875+ %- inde %+ ifix
876+ :- ;~ plug soqs
877+ ;~(pose ;~(plug (plus ace) vul) (just '\0a'))
878+ ==
879+ ;~(plug (just '\0a') soqs)
880+ (boss 256 (star qat))
881+ ==
882+ ::
883+```
884+
885+#### Examples
886+
887+```
888+ > (scan "'cord'" qut)
889+ q=1.685.221.219
890+ > 'cord'
891+ 'cord'
892+ > `@ud`'cord'
893+ 1.685.221.219
894+ > '''
895+ Heredoc isn't prohibited from containing quotes
896+ '''
897+ 'Heredoc isn't prohibited from containing quotes'
898+```
899+
900+
901+---
902+### `++soz`
903+
904+Delimiting `'''`
905+
906+Parse a triple-single quote, used for multiline strings.
907+
908+#### Source
909+
910+```
911+ ++ soz ;~(plug soq soq soq) :: delimiting '''
912+```
913+
914+#### Examples
915+
916+```
917+ > (scan "'''" soz)
918+ [~~~27. ~~~27. ~~~27.]
919+ > (rash '"""' soz)
920+ ! {1 1}
921+ ! exit
922+```
923+
924+
925+---
926+### `++sym`
927+
928+Term
929+
930+A term: a letter(lowercase), followed by letters, numbers, or `-`.
931+
932+#### Source
933+
934+```
935+ ++ sym
936+ %+ cook
937+ |=(a=tape (rap 3 ^-((list ,@) a)))
938+ ;~(plug low (star ;~(pose nud low hep)))
939+ ::
940+```
941+
942+#### Examples
943+
944+```
945+ > (scan "sam-2" sym)
946+ 215.510.507.891
947+ > `@t`(scan "sam-2" sym)
948+ 'sam-2'
949+ > (scan "sym" sym)
950+ 7.174.515
951+```
952+
953+
954+---
955+### `++ven`
956+
957+`+>-` axis syntax
958+
959+Axis syntax parser
960+
961+#### Source
962+
963+```
964+ ++ ven ;~ (comp |=({a/@ b/@} (peg a b))) :: +>- axis syntax
965+ bet
966+ =+ hom=`?`|
967+ |= tub/nail
968+ ^- (like axis)
969+ =+ vex=?:(hom (bet tub) (gul tub))
970+ ?~ q.vex
971+ [p.tub [~ 1 tub]]
972+ =+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex)
973+ ?> ?=(^ q.wag)
974+ [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]]
975+ ==
976+```
977+
978+#### Examples
979+
980+```
981+ ~zod/arvo=/hoon/hoon> (scan "->+" ven)
982+ 11
983+
984+ ~zod/arvo=/hoon/hoon> `@ub`(scan "->+" ven)
985+ 0b1011
986+
987+ ~zod/arvo=/hoon/hoon> (peg (scan "->" ven) (scan "+" ven))
988+ 11
989+
990+ ~zod/arvo=/hoon/hoon> ->+:[[1 2 [3 4]] 5]
991+ [3 4]
992+```
993+
994+
995+---
996+### `++vit`
997+
998+Base64 digit
999+
1000+Parse a standard base64 digit.
1001+
1002+#### Source
1003+
1004+```
1005+ ++ vit :: base64 digit
1006+ ;~ pose
1007+ (cook |=(a/@ (sub a 65)) (shim 'A' 'Z'))
1008+ (cook |=(a/@ (sub a 71)) (shim 'a' 'z'))
1009+ (cook |=(a/@ (add a 4)) (shim '0' '9'))
1010+ (cold 62 (just '-'))
1011+ (cold 63 (just '+'))
1012+ ==
1013+```
1014+
1015+#### Examples
1016+
1017+```
1018+ ~zod/arvo=/hoon/hoon> (scan "C" vit)
1019+ 2
1020+ ~zod/arvo=/hoon/hoon> (scan "c" vit)
1021+ 28
1022+ ~zod/arvo=/hoon/hoon> (scan "2" vit)
1023+ 54
1024+ ~zod/arvo=/hoon/hoon> (scan "-" vit)
1025+ 62
1026+```
1027+
1028+---
1029+### `++vul`
1030+
1031+Comments to null
1032+
1033+#### Source
1034+
1035+```
1036+ ++ vul %+ cold ~ :: comments
1037+ ;~ plug col col
1038+ (star prn)
1039+ (just `@`10)
1040+ ==
1041+```
1042+
1043+Parse comments and produce a null. Note that a comment must be ended
1044+with a newline character.
1045+
1046+#### Examples
1047+
1048+```
1049+ > (scan "::this is a comment \0a" vul)
1050+ ~
1051+ > (scan "::this is a comment " vul)
1052+ ! {1 21}
1053+ ! exit
1054+```
1055+
1056+
1057+---
reference/library/4k.udon−1048
@@ -276,1052 +276,4 @@ Renders a coin `lot` as a tape.
276276```
277277
278278
279−---
280−### `++alf`
281−
282−Alphabetic characters
283−
284−Parse alphabetic characters, both upper and lowercase.
285−
286−#### Source
287−
288−```
289− ++ alf ;~(pose low hig) :: alphabetic
290−```
291−
292−#### Examples
293−
294−```
295− > (scan "a" alf)
296− ~~a
297−
298− > (scan "A" alf)
299− ~~~41.
300−
301− > (scan "AaBbCc" (star alf))
302− "AaBbCc"
303−```
304−
305−
306−---
307−### `++aln`
308−
309−Alphanumeric characters
310−
311−Parse alphanumeric characters - both alphabetic characters and numbers.
312−
313−#### Source
314−
315−```
316− ++ aln ;~(pose low hig nud) :: alphanumeric
317−```
318−
319−#### Examples
320−
321−```
322− > (scan "0" aln)
323− ~~0
324−
325− > (scan "alf42" (star aln))
326− "alf42"
327−
328− > (scan "0123456789abcdef" (star aln))
329− "0123456789abcdef"
330−```
331−
332−
333−---
334−### `++alp`
335−
336−Alphanumeric and `-`
337−
338−Parse alphanumeric strings and hep, "-".
339−
340−#### Source
341−
342−```
343− ++ alp ;~(pose low hig nud hep) :: alphanumeric and -
344−```
345−
346−#### Examples
347−
348−```
349− > (scan "7" alp)
350− ~~7
351−
352− > (scan "s" alp)
353− ~~s
354−
355− > (scan "123abc-" (star alp))
356− "123abc-"
357−```
358−
359−
360−---
361−
362−### `++bet`
363−
364−Axis syntax `-`, `+`
365−
366−Parse the hep and lus axis syntax.
367−
368−#### Source
369−
370−```
371− ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - +
372−```
373−
374−#### Examples
375−
376−```
377− > (scan "-" bet)
378− 2
379−
380− > (scan "+" bet)
381− 3
382−```
383−
384−
385−---
386−### `++bin`
387−
388−Binary to atom
389−
390−Parse a tape of binary (0s and 1s) and produce its atomic representation.
391−
392−#### Source
393−
394−```
395− ++ bin (bass 2 (most gon but)) :: binary to atom
396−```
397−
398−#### Examples
399−
400−```
401− > (scan "0000" bin)
402− 0
403−
404− > (scan "0001" bin)
405− 1
406−
407− > (scan "0010" bin)
408− 2
409−
410− > (scan "100000001111" bin)
411− 2.063
412−```
413−
414−
415−---
416−### `++but`
417−
418−Binary digit
419−
420−Parse a single binary digit.
421−
422−#### Source
423−
424−```
425− ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit
426−```
427−
428−#### Examples
429−
430−```
431− > (scan "0" but)
432− 0
433− > (scan "1" but)
434− 1
435− > (scan "01" but)
436− ! {1 2}
437− ! 'syntax-error'
438− ! exit
439− > (scan "01" (star but))
440− ~[0 1]
441−```
442−
443−
444−---
445−### `++cit`
446−
447−Octal digit
448−
449−Parse a single octal digit.
450−
451−#### Source
452−
453−```
454− ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit
455−```
456−
457−#### Examples
458−
459−```
460− > (scan "1" cit)
461− 1
462− > (scan "7" cit)
463− 7
464− > (scan "8" cit)
465− ! {1 1}
466− ! 'syntax-error'
467− ! exit
468− > (scan "60" (star cit))
469− ~[6 0]
470−```
471−
472−
473−---
474−### `++dem`
475−
476−Decimal to atom
477−
478−Parse a decimal number to an atom.
479−
480−#### Source
481−
482−```
483− ++ dem (bass 10 (most gon dit)) :: decimal to atom
484−```
485−
486−#### Examples
487−
488−```
489− > (scan "7" dem)
490− 7
491− > (scan "42" dem)
492− 42
493− > (scan "150000000" dem)
494− 150.000.000
495− > (scan "12456" dem)
496− 12.456
497−```
498−
499−
500−---
501−### `++dit`
502−
503−Decimal digit
504−
505−Parse a single decimal digit.
506−
507−#### Source
508−
509−```
510− ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit
511−```
512−
513−#### Examples
514−
515−```
516− > (scan "7" dit)
517− 7
518− > (scan "42" (star dit))
519− ~[4 2]
520− > (scan "26000" (star dit))
521− ~[2 6 0 0 0]
522−```
523−
524−
525−---
526−### `++dog`
527−
528−`.` optional gap
529−
530−Dot followed by an optional gap, used with numbers.
531−
532−#### Source
533−
534−```
535− ++ dog ;~(plug dot gay) ::
536−```
537−
538−#### Examples
539−
540−```
541− > 1.234.703
542− 703
543− 1.234.703
544−
545− > (scan "a. " ;~(pfix alf dog))
546− [~~~. ~]
547−```
548−
549−
550−---
551−### `++doh`
552−
553−`@p` separator
554−
555−Phonetic base phrase separator
556−
557−#### Source
558−
559−```
560− ++ doh ;~(plug ;~(plug hep hep) gay) ::
561−```
562−
563−#### Examples
564−
565−```
566− /> ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
567− ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
568− /> ~nopfel-botduc-nilnev-dolfyn--
569− haspub-natlun-lodmur-holtyd
570− ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
571− > (scan "--" doh)
572− [[~~- ~~-] ~]
573− > (scan "-- " doh)
574− [[~~- ~~-] ~]
575−```
576−
577−
578−---
579−### `++dun`
580−
581−`--` to `~`
582−
583−Parse phep, `--`, to null, `~`.
584−
585−#### Source
586−
587−```
588− ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~
589−```
590−
591−#### Examples
592−
593−```
594− > (scan "--" dun)
595− ~
596− > (dun [[1 1] "--"])
597− [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=""]]]]
598−```
599−
600−
601−---
602−
603−### `++duz`
604−
605−`==` to `~`
606−
607−Parse stet, `==`, to null `~`.
608−
609−#### Source
610−
611−```
612− ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
613−```
614−
615−#### Examples
616−
617−```
618− > (scan "==" duz)
619− ~
620− > (duz [[1 1] "== |=..."])
621− [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=" |=..."]]]]
622−```
623−
624−
625−---
626−
627−### `++gah`
628−
629−Newline or ' '
630−
631−Whitespace component, either newline or space.
632−
633−#### Source
634−
635−```
636− ++ gah (mask [`@`10 ' ' ~]) :: newline or ace
637−```
638−
639−#### Examples
640−
641−```
642− /> ^- * :: show spaces
643− """
644− -
645− -
646− -
647− """
648− [32 32 32 45 10 32 45 10 32 32 45 0]
649− /> ^- *
650− """
651−
652− """
653− [32 32 32 10 32 10 32 32 0]
654− /> ^- (list ,@)
655− %- scan :_ (star gah)
656− """
657−
658− """
659− ~[32 32 32 10 32 10 32 32]
660−```
661−
662−
663−---
664−### `++gap`
665−
666−Plural whitespace
667−
668−Separates tall runes
669−
670−#### Source
671−
672−```
673− ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) :: plural whitespace
674−```
675−
676−
677−---
678−### `++gaq`
679−
680−End of line
681−
682−Two spaces, a newline, or comment.
683−
684−#### Source
685−
686−```
687− ++ gaq ;~ pose :: end of line
688− (just `@`10)
689− ;~(plug gah ;~(pose gah vul))
690− vul
691− ==
692−```
693−
694−
695−
696−---
697−### `++gaw`
698−
699−Classic whitespace
700−
701−Terran whitespace.
702−
703−#### Source
704−
705−```
706− ++ gaw (cold ~ (star ;~(pose vul gah))) :: classic white
707−```
708−
709−
710−---
711−### `++gay`
712−
713−Optional gap
714−
715−Optional gap.
716−
717−#### Source
718−
719−```
720− ++ gay ;~(pose gap (easy ~)) ::
721−```
722−
723−---
724−### `++gon`
725−
726−Long numbers
727−
728−Parse long numbers - Numbers which wrap around the shell with the line
729−
730−#### Source
731−
732−```
733− ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ /
734−```
735−
736−#### Examples
737−
738−```
739− > (scan "\\/" gon)
740− [~~~5c. ~ ~~~2f.]
741−
742− > (gon [[1 1] "\\/"])
743− [p=[p=1 q=3] q=[~ u=[p=[~~~5c. ~ ~~~2f.] q=[p=[p=1 q=3] q=""]]]]
744−```
745−
746−
747−---
748−### `++gul`
749−
750−Axis syntax `<` or `>`
751−
752−Parse the axis gal and gar axis syntax.
753−
754−#### Source
755−
756−```
757− ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < >
758−```
759−
760−#### Examples
761−
762−```
763− > (scan "<" gul)
764− 2
765−
766− > (scan ">" gul)
767− 3
768−```
769−
770−
771−---
772−### `++hex`
773−
774−Hex to atom
775−
776−Parse any hexadecimal number to an atom.
777−
778−#### Source
779−
780−```
781− ++ hex (bass 16 (most gon hit)) :: hex to atom
782−```
783−
784−#### Examples
785−
786−```
787− > (scan "a" hex)
788− 10
789− > (scan "A" hex)
790− 10
791− > (scan "2A" hex)
792− 42
793− > (scan "1ee7" hex)
794− 7.911
795− > (scan "1EE7" hex)
796− 7.911
797− > (scan "1EE7F7" hex)
798− 2.025.463
799− > `@ux`(scan "1EE7F7" hex)
800− 0x1e.e7f7
801−```
802−
803−---
804−### `++hig`
805−
806−Uppercase
807−
808−Parse a single uppercase letter.
809−
810−#### Source
811−
812−```
813− ++ hig (shim 'A' 'Z') :: uppercase
814−```
815−
816−#### Examples
817−
818−```
819− > (scan "G" hig)
820− ~~~47.
821−
822− > `cord`(scan "G" hig)
823− 'G'
824−
825− > (scan "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (star hig))
826− "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
827−
828− > (hig [[1 1] "G"])
829− [p=[p=1 q=2] q=[~ [p=~~~47. q=[p=[p=1 q=2] q=""]]]]
830−```
831−
832−
833−---
834−### `++hit`
835−
836−Hex digits
837−
838−Parse a single hexadecimal digit.
839−
840−#### Source
841−
842−```
843− ++ hit ;~ pose :: hex digits
844− dit
845− (cook |=(a=char (sub a 87)) (shim 'a' 'f'))
846− (cook |=(a=char (sub a 55)) (shim 'A' 'F'))
847− ==
848−```
849−
850−#### Examples
851−
852−```
853− > (scan "a" hit)
854− 10
855− > (scan "A" hit)
856− 10
857− > (hit [[1 1] "a"])
858− [p=[p=1 q=2] q=[~ [p=10 q=[p=[p=1 q=2] q=""]]]]
859− > (scan "2A" (star hit))
860− ~[2 10]
861−```
862−
863−---
864−### `++iny`
865−
866−Indentation block
867−
868−Apply `++rule` to indented block starting at current column number, omitting
869−the leading whitespace.
870−
871−#### Accepts
872−
873−`sef` is a `++rule`
874−
875−#### Produces
876−
877−A `++rule`.
878−
879−#### Source
880−
881−```
882− ++ inde |* sef/rule :: indentation block
883− |= nail ^+ (sef)
884− =+ [har tap]=[p q]:+<
885− =+ lev=(fil 3 (dec q.har) ' ')
886− =+ eol=(just `@t`10)
887− =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap)
888− ;~(simu ;~(plug eol eol) eol)
889− ?~ q.roq roq
890− =+ vex=(sef har(q 1) p.u.q.roq)
891− =+ fur=p.vex(q (add (dec q.har) q.p.vex))
892− ?~ q.vex vex(p fur)
893− =- vex(p fur, u.q -)
894− :+ &3.vex
895− &4.vex(q.p (add (dec q.har) q.p.&4.vex))
896− =+ res=|4.vex
897− |- ?~ res |4.roq
898− ?. =(10 -.res) [-.res $(res +.res)]
899− (welp [`@t`10 (trip lev)] $(res +.res))
900− ::
901−```
902−
903−#### Examples
904−
905−```
906− > (scan "abc" (iny (star ;~(pose prn (just `@`10)))))
907− "abc"
908− > (scan "abc" (star ;~(pose prn (just `@`10))))
909− "abc"
910− > (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10)))))
911− "abc
912− de"
913− > (scan " abc\0ade" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
914− ! {1 6}
915− ! exit
916− > (scan " abc\0a de" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
917− "abc
918− de"
919−```
920−
921−
922−---
923−### `++low`
924−
925−Lowercase
926−
927−Parse a single lowercase letter.
928−
929−#### Source
930−
931−```
932− ++ low (shim 'a' 'z') :: lowercase
933−```
934−
935−#### Examples
936−
937−```
938− > (scan "g" low)
939− ~~g
940− > `cord`(scan "g" low)
941− 'g'
942− > (scan "abcdefghijklmnopqrstuvwxyz" (star low))
943− "abcdefghijklmnopqrstuvwxyz"
944− > (low [[1 1] "g"])
945− [p=[p=1 q=2] q=[~ [p=~~g q=[p=[p=1 q=2] q=""]]]]
946−```
947−
948−
949−---
950−### `++mes`
951−
952−Hexbyte
953−
954−Parse a hexbyte.
955−
956−#### Source
957−
958−```
959− ++ mes %+ cook :: hexbyte
960− |=({a/@ b/@} (add (mul 16 a) b))
961− ;~(plug hit hit)
962−```
963−
964−#### Examples
965−
966−```
967− > (scan "2A" mes)
968− 42
969− > (mes [[1 1] "2A"])
970− [p=[p=1 q=3] q=[~ u=[p=42 q=[p=[p=1 q=3] q=""]]]]
971− > (scan "42" mes)
972− 66
973−```
974−
975−
976−---
977−### `++nix`
978−
979−Letters and `-`
980−
981−Parse Letters and `-`.
982−
983−#### Source
984−
985−```
986− ++ nix (boss 256 (star ;~(pose aln cab))) ::
987−```
988−
989−#### Examples
990−
991−```
992− > (scan "as_me" nix)
993− q=435.626.668.897
994−
995− > `@t`(scan "as_me" nix)
996− 'as_me'
997−```
998−
999−
1000−---
1001−
1002−### `++nud`
1003−
1004−Numeric
1005−
1006−Parse a numeric character - A number.
1007−
1008−#### Source
1009−
1010−```
1011− ++ nud (shim '0' '9') :: numeric
1012−```
1013−
1014−#### Examples
1015−
1016−```
1017− > (scan "0" nud)
1018− ~~0
1019− > (scan "7" nud)
1020− ~~7
1021− > (nud [[1 1] "1"])
1022− [p=[p=1 q=2] q=[~ [p=~~1 q=[p=[p=1 q=2] q=""]]]]
1023− > (scan "0123456789" (star nud))
1024− "0123456789"
1025−```
1026−
1027−---
1028−### `++prn`
1029−
1030−Printable character
1031−
1032−Parse any printable character.
1033−
1034−#### Source
1035−
1036−```
1037− ++ prn ;~(less (just `@`127) (shim 32 256))
1038−```
1039−
1040−#### Examples
1041−
1042−```
1043− > (scan "h" prn)
1044− ~~h
1045− > (scan "!" prn)
1046− ~~~21.
1047− > (scan "\01" prn)
1048− ! {1 1}
1049− ! exit
1050−```
1051−
1052−
1053−---
1054−### `++qit`
1055−
1056−Chars in cord
1057−
1058−Parse an individual character to its cord atom representation.
1059−
1060−#### Source
1061−
1062−```
1063− ++ qit ;~ pose :: chars in a cord
1064− ;~(less bas soq prn)
1065− ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
1066− ==
1067−```
1068−
1069−#### Examples
1070−
1071−```
1072− > (scan "%" qit)
1073− 37
1074− > `@t`(scan "%" qit)
1075− '%'
1076− > (scan "0" qit)
1077− 48
1078− > (scan "E" qit)
1079− 69
1080− > (scan "a" qit)
1081− 97
1082− > (scan "\\0a" qit)
1083− 10
1084− > `@ux`(scan "\\0a" qit)
1085− 0xa
1086− > (scan "cord" (star qit))
1087− ~[99 111 114 100]
1088−```
1089−
1090−
1091−---
1092−### `++qit`
1093−
1094−Chars in cord
1095−
1096−Parse an individual character to its cord atom representation.
1097−
1098−#### Source
1099−
1100−```
1101− ++ qit ;~ pose :: chars in a cord
1102− ;~(less bas soq prn)
1103− ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
1104− ==
1105−```
1106−
1107−#### Examples
1108−
1109−```
1110− > (scan "%" qit)
1111− 37
1112− > `@t`(scan "%" qit)
1113− '%'
1114− > (scan "0" qit)
1115− 48
1116− > (scan "E" qit)
1117− 69
1118− > (scan "a" qit)
1119− 97
1120− > (scan "\\0a" qit)
1121− 10
1122− > `@ux`(scan "\\0a" qit)
1123− 0xa
1124− > (scan "cord" (star qit))
1125− ~[99 111 114 100]
1126−```
1127−
1128−
1129−
1130−---
1131−### `++qut`
1132−
1133−Cord
1134−
1135−Parse single-soq cord with `\{gap}/` anywhere in the middle, or triple-single
1136−quote (aka triple-soq) cord, between which must be in an indented block.
1137−
1138−#### Source
1139−
1140−```
1141− ++ qut ;~ pose :: cord
1142− ;~ less soqs
1143− (ifix [soq soq] (boss 256 (more gon qit)))
1144− ==
1145− %- inde %+ ifix
1146− :- ;~ plug soqs
1147− ;~(pose ;~(plug (plus ace) vul) (just '\0a'))
1148− ==
1149− ;~(plug (just '\0a') soqs)
1150− (boss 256 (star qat))
1151− ==
1152− ::
1153−```
1154−
1155−#### Examples
1156−
1157−```
1158− > (scan "'cord'" qut)
1159− q=1.685.221.219
1160− > 'cord'
1161− 'cord'
1162− > `@ud`'cord'
1163− 1.685.221.219
1164− > '''
1165− Heredoc isn't prohibited from containing quotes
1166− '''
1167− 'Heredoc isn't prohibited from containing quotes'
1168−```
1169−
1170−
1171−---
1172−### `++soz`
1173−
1174−Delimiting `'''`
1175−
1176−Parse a triple-single quote, used for multiline strings.
1177−
1178−#### Source
1179−
1180−```
1181− ++ soz ;~(plug soq soq soq) :: delimiting '''
1182−```
1183−
1184−#### Examples
1185−
1186−```
1187− > (scan "'''" soz)
1188− [~~~27. ~~~27. ~~~27.]
1189− > (rash '"""' soz)
1190− ! {1 1}
1191− ! exit
1192−```
1193−
1194−
1195−---
1196−### `++sym`
1197−
1198−Term
1199−
1200−A term: a letter(lowercase), followed by letters, numbers, or `-`.
1201−
1202−#### Source
1203−
1204−```
1205− ++ sym
1206− %+ cook
1207− |=(a=tape (rap 3 ^-((list ,@) a)))
1208− ;~(plug low (star ;~(pose nud low hep)))
1209− ::
1210−```
1211−
1212−#### Examples
1213−
1214−```
1215− > (scan "sam-2" sym)
1216− 215.510.507.891
1217− > `@t`(scan "sam-2" sym)
1218− 'sam-2'
1219− > (scan "sym" sym)
1220− 7.174.515
1221−```
1222−
1223−
1224−---
1225−### `++ven`
1226−
1227−`+>-` axis syntax
1228−
1229−Axis syntax parser
1230−
1231−#### Source
1232−
1233−```
1234− ++ ven ;~ (comp |=({a/@ b/@} (peg a b))) :: +>- axis syntax
1235− bet
1236− =+ hom=`?`|
1237− |= tub/nail
1238− ^- (like axis)
1239− =+ vex=?:(hom (bet tub) (gul tub))
1240− ?~ q.vex
1241− [p.tub [~ 1 tub]]
1242− =+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex)
1243− ?> ?=(^ q.wag)
1244− [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]]
1245− ==
1246−```
1247−
1248−#### Examples
1249−
1250−```
1251− ~zod/arvo=/hoon/hoon> (scan "->+" ven)
1252− 11
1253−
1254− ~zod/arvo=/hoon/hoon> `@ub`(scan "->+" ven)
1255− 0b1011
1256−
1257− ~zod/arvo=/hoon/hoon> (peg (scan "->" ven) (scan "+" ven))
1258− 11
1259−
1260− ~zod/arvo=/hoon/hoon> ->+:[[1 2 [3 4]] 5]
1261− [3 4]
1262−```
1263−
1264−
1265−---
1266−### `++vit`
1267−
1268−Base64 digit
1269−
1270−Parse a standard base64 digit.
1271−
1272−#### Source
1273−
1274−```
1275− ++ vit :: base64 digit
1276− ;~ pose
1277− (cook |=(a/@ (sub a 65)) (shim 'A' 'Z'))
1278− (cook |=(a/@ (sub a 71)) (shim 'a' 'z'))
1279− (cook |=(a/@ (add a 4)) (shim '0' '9'))
1280− (cold 62 (just '-'))
1281− (cold 63 (just '+'))
1282− ==
1283−```
1284−
1285−#### Examples
1286−
1287−```
1288− ~zod/arvo=/hoon/hoon> (scan "C" vit)
1289− 2
1290− ~zod/arvo=/hoon/hoon> (scan "c" vit)
1291− 28
1292− ~zod/arvo=/hoon/hoon> (scan "2" vit)
1293− 54
1294− ~zod/arvo=/hoon/hoon> (scan "-" vit)
1295− 62
1296−```
1297−
1298−---
1299−### `++vul`
1300−
1301−Comments to null
1302−
1303−#### Source
1304−
1305−```
1306− ++ vul %+ cold ~ :: comments
1307− ;~ plug col col
1308− (star prn)
1309− (just `@`10)
1310− ==
1311−```
1312−
1313−Parse comments and produce a null. Note that a comment must be ended
1314−with a newline character.
1315−
1316−#### Examples
1317−
1318−```
1319− > (scan "::this is a comment \0a" vul)
1320− ~
1321− > (scan "::this is a comment " vul)
1322− ! {1 21}
1323− ! exit
1324−```
1325−
1326−
1327279---