@@ -4,3173 +4,104 @@
44section 2cA, bit surgery
55------------------------
66
7−### `++bex`
8−
9−Binary exponent
10−
11−Computes the result of `2^a`, producing an [atom]().
12−
13−Accepts
14−-------
15−
16−`a` is an atom.
17−
18−Produces
19−--------
20−
21−An atom.
22−
23−Source
24−------
25−
26− ++ bex :: binary exponent
27− ~/ %bex
28− |= a=@
29− ^- @
30− ?: =(0 a) 1
31− (mul 2 $(a (dec a)))
32−
33−Examples
34−--------
35−
36− ~zod/try=> (bex 4)
37− 16
38− ~zod/try=> (bex (add 19 1))
39− 1.048.576
40− ~zod/try=> (bex 0)
41− 1
42−
43−------------------------------------------------------------------------
44−
45−### `++xeb`
46−
47−Binary logarithm
48−
49−Computes the base-2 logarithm of `a`, producing an [atom]().
50−
51−Accepts
52−-------
53−
54−`a` is an atom.
55−
56−Produces
57−--------
58−
59−An atom.
60−
61−Source
62−------
63−
64− ++ xeb :: binary logarithm
65− :: ~/ %xeb
66− |= a=@
67− ^- @
68− (met 0 a)
69−
70−Examples
71−--------
72−
73− ~zod/try=> (xeb 31)
74− 5
75− ~zod/try=> (xeb 32)
76− 6
77− ~zod/try=> (xeb 49)
78− 6
79− ~zod/try=> (xeb 0)
80− 0
81− ~zod/try=> (xeb 1)
82− 1
83− ~zod/try=> (xeb 2)
84− 2
85−
86−------------------------------------------------------------------------
87−
88−### `++can`
89−
90−Assemble
91−
92−Produces an [atom]() from a list `b` of length-value pairs `p` and `q`,
93−where `p` is the length in bloqs of size `a`, and `q` is an atomic
94−value.
95−
96−Accepts
97−-------
98−
99−`a` is a block size (see [`++bloq`]()).
100−
101−`b` is a [`++list`]() of length value pairs, `p` and `q`.
102−
103−Produces
104−--------
105−
106−An atom.
107−
108−Source
109−------
110−
111− ++ can :: assemble
112− ~/ %can
113− |= [a=bloq b=(list ,[p=@ q=@])]
114− ^- @
115− ?~ b 0
116− (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
117−
118−Examples
119−--------
120−
121− ~zod/try=> `@ub`(can 3 ~[[1 1]])
122− 0b1
123− ~zod/try=> `@ub`(can 0 ~[[1 255]])
124− 0b1
125− ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] ~)
126− 0xa00.00c1
127− ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
128− 0x23.0a00.00c1
129− ~zod/try=> `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
130− 0x23.000a.0000.0000.00c1
131− ~zod/try=> `@ux`(can 3 ~[[1 'a'] [2 'bc']])
132− 0x63.6261
133−
134−------------------------------------------------------------------------
135−
136−### `++cat`
137−
138−Concatenate
139−
140−Concatenates two [atom]()s, `b` and `c`, according to bloq size `a`, producing an
141−atom.
142−
143−Accepts
144−-------
145−
146−`a` is a block size (see [`++bloq`]()).
147−
148−`b` is an atom.
149−
150−`c` is an atom.
151−
152−Produces
153−--------
154−
155−An atom.
156−
157−Source
158−------
159−
160− ++ cat :: concatenate
161− ~/ %cat
162− |= [a=bloq b=@ c=@]
163− (add (lsh a (met a b) c) b)
164−
165−Examples
166−--------
167−
168− ~zod/try=> `@ub`(cat 3 1 0)
169− 0b1
170− ~zod/try=> `@ub`(cat 0 1 1)
171− 0b11
172− ~zod/try=> `@ub`(cat 0 2 1)
173− 0b110
174− ~zod/try=> `@ub`(cat 2 1 1)
175− 0b1.0001
176− ~zod/try=> `@ub`256
177− 0b1.0000.0000
178− ~zod/try=> `@ub`255
179− 0b1111.1111
180− ~zod/try=> `@ub`(cat 3 256 255)
181− 0b1111.1111.0000.0001.0000.0000
182− ~zod/try=> `@ub`(cat 2 256 255)
183− 0b1111.1111.0001.0000.0000
184− ~zod/try=> (cat 3 256 255)
185− 16.711.936
186−
187−------------------------------------------------------------------------
188−
189−### `++cut`
190−
191−Slice
192−
193−Slices `c` blocks of size `a` that are `b` blocks from the end of `d`.
194−
195−Accepts
196−-------
197−
198−`a` is a block size (see [++bloq]()).
199−
200−`b` is an [atom]().
201−
202−`c` is an atom.
203−
204−Produces
205−--------
206−
207−An atom.
208−
209−Source
210−------
211−
212− ++ cut :: slice
213− ~/ %cut
214− |= [a=bloq [b=@ c=@] d=@]
215− (end a c (rsh a b d))
216−
217−Examples
218−--------
219−
220− ~zod/try=> (cut 0 [1 1] 2)
221− 1
222− ~zod/try=> (cut 0 [2 1] 4)
223− 1
224− ~zod/try=> `@t`(cut 3 [0 3] 'abcdefgh')
225− 'abc'
226− ~zod/try=> `@t`(cut 3 [1 3] 'abcdefgh')
227− 'bcd'
228− ~zod/try=> `@ub`(cut 0 [0 3] 0b1111.0000.1101)
229− 0b101
230− ~zod/try=> `@ub`(cut 0 [0 6] 0b1111.0000.1101)
231− 0b1101
232− ~zod/try=> `@ub`(cut 0 [4 6] 0b1111.0000.1101)
233− 0b11.0000
234− ~zod/try=> `@ub`(cut 0 [3 6] 0b1111.0000.1101)
235− 0b10.0001
236−
237−------------------------------------------------------------------------
238−
239−### `++end`
240−
241−Tail
242−
243−Produces an [atom]() by taking the last `b` blocks of size `a` from `c`.
244−
245−Accepts
246−-------
247−
248−`a` is a block size (see [`++bloq`]()).
249−
250−`b` is an atom.
251−
252−`c` is an [atom]().
253−
254−Produces
255−--------
256−
257−An atom.
258−
259−
260−Source
261−------
262−
263− ++ end :: tail
264− ~/ %end
265− |= [a=bloq b=@ c=@]
266− (mod c (bex (mul (bex a) b)))
267−
268−Examples
269−--------
270−
271− ~zod/try=> `@ub`12
272− 0b1100
273− ~zod/try=> `@ub`(end 0 3 12)
274− 0b100
275− ~zod/try=> (end 0 3 12)
276− 4
277− ~zod/try=> `@ub`(end 1 3 12)
278− 0b1100
279− ~zod/try=> (end 1 3 12)
280− 12
281− ~zod/try=> `@ux`'abc'
282− 0x63.6261
283− ~zod/try=> `@ux`(end 3 2 'abc')
284− 0x6261
285− ~zod/try=> `@t`(end 3 2 'abc')
286− 'ab'
287−
288−------------------------------------------------------------------------
289−
290−### `++fil`
291−
292−Fill bloqstream
293−
294−Produces an [atom]() by repeating `c` for `b` blocks of size `a`.
295−
296−Accepts
297−-------
298−
299−`a` is a block size (see [`++bloq`]()).
300−
301−`b` is an atom.
302−
303−`c` is an [atom]().
304−
305−Produces
306−--------
307−
308−An atom.
309−
310−Source
311−------
312−
313− ++ fil :: fill bloqstream
314− |= [a=bloq b=@ c=@]
315− =+ n=0
316− =+ d=c
317− |- ^- @
318− ?: =(n b)
319− (rsh a 1 d)
320− $(d (add c (lsh a 1 d)), n +(n))
321−
322−Examples
323−--------
324−
325− ~zod/try=> `@t`(fil 3 5 %a)
326− 'aaaaa'
327− ~zod/try=> `@t`(fil 5 10 %ceeb)
328− 'ceebceebceebceebceebceebceebceebceebceeb'
329− ~zod/try=> `@t`(fil 4 10 %eced)
330− 'ʇʇʇʇʇʇʇʇʇʇed'
331− ~zod/try=> `@tas`(fil 4 10 %bf)
332− %bfbfbfbfbfbfbfbfbfbf
333−
334−------------------------------------------------------------------------
335−
336−### `++lsh`
337−
338−Left-shift
339−
340−Produces an [atom]() by left-shifting `c` by `b` blocks of size `a`.
341−
342−Accepts
343−-------
344−
345−`a` is a block size (see [`++bloq`]()).
346−
347−`b` is an atom.
348−
349−`c` is an atom.
350−
351−Produces
352−--------
353−
354−An atom.
355−
356−Source
357−------
358−
359− ++ lsh :: left-shift
360− ~/ %lsh
361− |= [a=bloq b=@ c=@]
362− (mul (bex (mul (bex a) b)) c)
363−
364−Examples
365−--------
366−
367− ~zod/try=> `@ub`1
368− 0b1
369− ~zod/try=> `@ub`(lsh 0 1 1)
370− 0b10
371− ~zod/try=> (lsh 0 1 1)
372− 2
373− ~zod/try=> `@ub`255
374− 0b1111.1111
375− ~zod/try=> `@ub`(lsh 3 1 255)
376− 0b1111.1111.0000.0000
377− ~zod/try=> (lsh 3 1 255)
378− 65.280
379−
380−------------------------------------------------------------------------
381−
382−### `++me
383−
384−Measure
385−
386−Computes the number of blocks of size `a` in `b`, producing an [atom]().
387−
388−`a` is a block size (see [`++bloq`]()).
389−
390−`b` is an atom.
391−
392−Source
393−------
394−
395− ++ met :: measure
396− ~/ %met
397− |= [a=bloq b=@]
398− ^- @
399− =+ c=0
400− |-
401− ?: =(0 b) c
402− $(b (rsh a 1 b), c +(c))
403−
404−Examples
405−--------
406−
407− ~zod/try=> (met 0 1)
408− 1
409− ~zod/try=> (met 0 2)
410− 2
411− ~zod/try=> (met 3 255)
412− 1
413− ~zod/try=> (met 3 256)
414− 2
415− ~zod/try=> (met 3 'abcde')
416− 5
417−
418−------------------------------------------------------------------------
419−
420−### `++rap`
421−
422−Assemble non-zero
423−
424−Concatenates a list of [atom]()s `b` using blocksize `a`, producing an atom.
425−
426−Accepts
427−-------
428−
429−`a` is a block size (see [`++bloq`]()).
430−
431−`b` is a [`++list`]() of [atom]()s.
432−
433−Produces
434−--------
435−
436−An atom.
437−
438−Source
439−------
440−
441− ++ rap :: assemble nonzero
442− ~/ %rap
443− |= [a=bloq b=(list ,@)]
444− ^- @
445− ?~ b 0
446− (cat a i.b $(b t.b))
447−
448−Examples
449−--------
450−
451− ~zod/try=> `@ub`(rap 2 (limo [1 2 3 4 ~]))
452− 0b100.0011.0010.0001
453− ~zod/try=> `@ub`(rap 1 (limo [1 2 3 4 ~]))
454− 0b1.0011.1001
455− ~zod/try=> (rap 0 (limo [0 0 0 ~]))
456− 0
457− ~zod/try=> (rap 0 (limo [1 0 1 ~]))
458− 3
459−
460−------------------------------------------------------------------------
461−
462−### `++rep`
463−
464−Assemble single
465−
466−Produces an [atom]() by assembling a list of atoms `b` using block size `a`.
467−
468−Accepts
469−-------
470−
471−`a` is a block size (see [`++bloq`]()).
472−
473−`b` is a list of atoms.
474−
475−Produces
476−--------
477−
478−An atom.
479−
480−Source
481−------
482−
483− ++ rep :: assemble single
484− ~/ %rep
485− |= [a=bloq b=(list ,@)]
486− ^- @
487− =+ c=0
488− |-
489− ?~ b 0
490− (con (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
491−
492−Examples
493−--------
494−
495− ~zod/try=> `@ub`(rep 2 (limo [1 2 3 4 ~]))
496− 0b100.0011.0010.0001
497− ~zod/try=> (rep 0 (limo [0 0 1 ~]))
498− 4
499− ~zod/try=> (rep 0 (limo [0 0 0 1 ~]))
500− 8
501− ~zod/try=> (rep 0 (limo [0 1 0 0 ~]))
502− 2
503− ~zod/try=> (rep 0 (limo [0 1 0 1 ~]))
504− 10
505− ~zod/try=> (rep 0 (limo [0 1 0 1 0 1 ~]))
506− 42
507− ~zod/try=> `@ub`42
508− 0b10.1010
509−
510−------------------------------------------------------------------------
511−
512−### `++rip`
513−
514−Disassemble
515−
516−Produces a list of [atom]()s from the bits of `b` using block size `a`.
517−
518−Accepts
519−-------
520−
521−`a` is a block size (see [`++bloq`]()).
522−
523−`b` is an atom.
524−
525−Produces
526−--------
527−
528−A list of atoms.
529−
530−Source
531−------
532−
533− ++ rip :: disassemble
534− ~/ %rip
535− |= [a=bloq b=@]
536− ^- (list ,@)
537− ?: =(0 b) ~
538− [(end a 1 b) $(b (rsh a 1 b))]
539−
540−Examples
541−--------
542−
543− ~zod/try=> `@ub`155
544− 0b1001.1011
545− ~zod/try=> (rip 0 155)
546− ~[1 1 0 1 1 0 0 1]
547− ~zod/try=> (rip 2 155)
548− ~[11 9]
549− ~zod/try=> (rip 1 155)
550− ~[3 2 1 2]
551− ~zod/try=> `@ub`256
552− 0b1.0000.0000
553− ~zod/try=> (rip 0 256)
554− ~[0 0 0 0 0 0 0 0 1]
555− ~zod/try=> (rip 2 256)
556− ~[0 0 1]
557− ~zod/try=> (rip 3 256)
558− ~[0 1]
559−
560−------------------------------------------------------------------------
561−
562−### `++rsh`
563−
564−Right-shift
565−
566−Right-shifts `c` by `b` blocks of size `a`, producing an [atom]().
567−
568−Accepts
569−-------
570−
571−`a` is a block size (see [`++bloq`]()).
572−
573−`b` is an atom.
574−
575−`c` is an atom.
576−
577−Produces
578−--------
579−
580−An atom.
581−
582−Source
583−------
584−
585− ++ rsh :: right-shift
586− ~/ %rsh
587− |= [a=bloq b=@ c=@]
588− (div c (bex (mul (bex a) b)))
589−
590−Examples
591−--------
592−
593− ~zod/try=> `@ub`145
594− 0b1001.0001
595− ~zod/try=> `@ub`(rsh 1 1 145)
596− 0b10.0100
597− ~zod/try=> (rsh 1 1 145)
598− 36
599− ~zod/try=> `@ub`(rsh 2 1 145)
600− 0b1001
601− ~zod/try=> (rsh 2 1 145)
602− 9
603− ~zod/try=> `@ub`10
604− 0b1010
605− ~zod/try=> `@ub`(rsh 0 1 10)
606− 0b101
607− ~zod/try=> (rsh 0 1 10)
608− 5
609− ~zod/try=> `@ux`'abc'
610− 0x63.6261
611− ~zod/try=> `@t`(rsh 3 1 'abc')
612− 'bc'
613− ~zod/try=> `@ux`(rsh 3 1 'abc')
614− 0x6362
615−
616−------------------------------------------------------------------------
617−
618−### `++swap`
619−
620−Reverse block order
621−
622−Switches little endian to big and vice versa: produces an [atom]() by
623−reversing the block order of `b` using block size `a`.
624−
625−
626−Accepts
627−-------
628−
629−`a` is a block size (see [`++bloq`]()).
630−
631−`b` is an atom.
632−
633−Produces
634−--------
635−
636−An atom
637−
638−Source
639−------
640−
641− ++ swap |=([a=bloq b=@] (rep a (flop (rip a b)))) :: reverse bloq order
642−
643−Examples
644−--------
645−
646− ~zod/try=> `@ub`24
647− 0b1.1000
648− ~zod/try=> (swap 0 24)
649− 3
650− ~zod/try=> `@ub`3
651− 0b11
652− ~zod/try=> (swap 0 0)
653− 0
654− ~zod/try=> (swap 0 128)
655− 1
656−
657−------------------------------------------------------------------------
658−
659−section 2cB, bit logic
660−----------------------
661−
662−### `++con`
663−
664−Binary OR
665−
666−Computes the bit-wise logical OR of two [atom]()s, `a` and `b`, producing an
667−atom.
668−
669−Accepts
670−-------
671−
672−`a` is an atom
673−
674−`b` is an atom
675−
676−Produces
677−--------
678−
679−An atom.
680−
681−Source
682−------
683−
684− ++ con :: binary or
685− ~/ %con
686− |= [a=@ b=@]
687− =+ [c=0 d=0]
688− |- ^- @
689− ?: ?&(=(0 a) =(0 b)) d
690− %= $
691− a (rsh 0 1 a)
692− b (rsh 0 1 b)
693− c +(c)
694− d %+ add d
695− %^ lsh 0 c
696− ?& =(0 (end 0 1 a))
697− =(0 (end 0 1 b))
698− ==
699− ==
700−
701−Examples
702−--------
703−
704− ~zod/try=> (con 0b0 0b1)
705− 1
706− ~zod/try=> (con 0 1)
707− 1
708− ~zod/try=> (con 0 0)
709− 0
710− ~zod/try=> `@ub`(con 0b1111.0000 0b1.0011)
711− 0b1111.0011
712− ~zod/try=> (con 4 4)
713− 4
714− ~zod/try=> (con 10.000 234)
715− 10.234
716−
717−------------------------------------------------------------------------
718−
719−### `++dis`
720−
721−Binary AND
722−
723−Computes the bit-wise logical AND of two [atom]()s `a` and `b`, producing an
724−atom.
725−
726−Accepts
727−-------
728−
729−`a` is an atom.
730−
731−`b` is an atom.
732−
733−Produces
734−--------
735−
736−An atom.
737−
738−Source
739−------
740−
741− ++ dis :: binary and
742− ~/ %dis
743− |= [a=@ b=@]
744− =| [c=@ d=@]
745− |- ^- @
746− ?: ?|(=(0 a) =(0 b)) d
747− %= $
748− a (rsh 0 1 a)
749− b (rsh 0 1 b)
750− c +(c)
751− d %+ add d
752− %^ lsh 0 c
753− ?| =(0 (end 0 1 a))
754− =(0 (end 0 1 b))
755− ==
756− ==
757−
758−Examples
759−--------
760−
761− ~zod/try=> `@ub`9
762− 0b1001
763− ~zod/try=> `@ub`5
764− 0b101
765− ~zod/try=> `@ub`(dis 9 5)
766− 0b1
767− ~zod/try=> (dis 9 5)
768− 1
769− ~zod/try=> `@ub`534
770− 0b10.0001.0110
771− ~zod/try=> `@ub`987
772− 0b11.1101.1011
773− ~zod/try=> `@ub`(dis 534 987)
774− 0b10.0001.0010
775− ~zod/try=> (dis 534 987)
776− 530
777−
778−------------------------------------------------------------------------
779−
780−### `++mix`
781−
782−Binary XOR
783−
784−Produces the bit-wise logical XOR of `a` and `b`, producing an [atom]().
785−
786−Accepts
787−-------
788−
789−`a` is an atom
790−
791−`b` is an atom
792−
793−Produces
794−--------
795−
796−An atom.
797−
798−Source
799−------
800−
801− ++ mix :: binary xor
802− ~/ %mix
803− |= [a=@ b=@]
804− ^- @
805− =+ [c=0 d=0]
806− |-
807− ?: ?&(=(0 a) =(0 b)) d
808− %= $
809− a (rsh 0 1 a)
810− b (rsh 0 1 b)
811− c +(c)
812− d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b))))
813− ==
814−
815−Examples
816−--------
817−
818− ~zod/try=> `@ub`2
819− 0b10
820− ~zod/try=> `@ub`3
821− 0b11
822− ~zod/try=> `@ub`(mix 2 3)
823− 0b1
824− ~zod/try=> (mix 2 3)
825− 1
826− ~zod/try=> `@ub`(mix 2 2)
827− 0b0
828− ~zod/try=> (mix 2 2)
829− 0
830−
831−------------------------------------------------------------------------
832−
833−### `++not`
834−
835−Binary NOT
836−
837−Computes the bit-wise logical NOT of the bottom `b` blocks of size `a`
838−of `c`.
839−
840−Accepts
841−-------
842−
843−`a` is a block size (see [`++bloq`]()).
844−
845−`b` is an [atom]().
846−
847−`c` is an atom.
848−
849−Produces
850−--------
851−
852−An atom.
853−
854−Source
855−------
856−
857− ++ not |= [a=bloq b=@ c=@] :: binary not (sized)
858− (mix c (dec (bex (mul b (bex a)))))
859−
860−Examples
861−--------
862−
863− ~zod/try=> `@ub`24
864− 0b1.1000
865− ~zod/try=> (not 0 5 24)
866− 7
867− ~zod/try=> `@ub`7
868− 0b111
869− ~zod/try=> (not 2 5 24)
870− 1.048.551
871− ~zod/try=> (not 2 5 1.048.551)
872− 24
873− ~zod/try=> (not 1 1 (not 1 1 10))
874− 10
875−
876−------------------------------------------------------------------------
877−
878−section 2cC, noun orders
879−------------------------
880−
881−### `++aor`
882−
883−Alphabetic order
884−
885−Computes whether `a` and `b` are in alphabetical order, producing a
886−boolean.
887−
888−Accepts
889−-------
890−
891−`a` is a [noun]().
892−
893−`b` is a noun.
894−
895−Produces
896−--------
897−
898−A boolean atom.
899−
900−
901−Source
902−------
903−
904− ++ aor :: alphabetic-order
905− ~/ %aor
906− |= [a=* b=*]
907− ^- ?
908− ?: =(a b) &
909− ?. ?=(@ a)
910− ?: ?=(@ b) |
911− ?: =(-.a -.b)
912− $(a +.a, b +.b)
913− $(a -.a, b -.b)
914− ?. ?=(@ b) &
915− |-
916− =+ [c=(end 3 1 a) d=(end 3 1 b)]
917− ?: =(c d)
918− $(a (rsh 3 1 a), b (rsh 3 1 b))
919− (lth c d)
920−
921−Examples
922−--------
923−
924− ~zod/try=> (aor 'a' 'b')
925− %.y
926− ~zod/try=> (aor 'b' 'a')
927− %.n
928− ~zod/try=> (aor "foo" "bar")
929− %.n
930− ~zod/try=> (aor "bar" "foo")
931− %.y
932− ~zod/try=> (aor "abcdefz" "abcdefa")
933− %.n
934− ~zod/try=> (aor "abcdefa" "abcdefz")
935− %.y
936− ~zod/try=> (aor 10.000 17.000)
937− %.y
938− ~zod/try=> (aor 10 9)
939− %.n
940−
941−------------------------------------------------------------------------
942−
943−### `++dor`
944−
945−Numeric order
946−
947−Computes whether `a` and `b` are in ascending numeric order, producing a
948−boolean.
949−
950−Accepts
951−-------
952−
953−`a` is a [noun]().
954−
955−`b` is a noun.
956−
957−Produces
958−--------
959−
960−A boolean atom.
961−
962−Source
963−------
964−
965− ++ dor :: d-order
966− ~/ %dor
967− |= [a=* b=*]
968− ^- ?
969− ?: =(a b) &
970− ?. ?=(@ a)
971− ?: ?=(@ b) |
972− ?: =(-.a -.b)
973− $(a +.a, b +.b)
974− $(a -.a, b -.b)
975− ?. ?=(@ b) &
976− (lth a b)
977−
978−Examples
979−--------
980−
981− ~zod/try=> (dor 1 2)
982− %.y
983− ~zod/try=> (dor 2 1)
984− %.n
985− ~zod/try=> (dor ~[1 2 3] ~[1 2 4])
986− %.y
987− ~zod/try=> (dor ~[1 2 4] ~[1 2 3])
988− %.n
989− ~zod/try=> (dor (limo ~[99 100 10.000]) ~[99 101 10.000])
990− %.y
991− ~zod/try=> (dor ~[99 101 10.999] (limo ~[99 100 10.000]))
992− %.n
993−
994−------------------------------------------------------------------------
995−
996−### `++gor`
997−
998−Hash order
999−
1000−XX revisit
1001−
1002−Accepts
1003−-------
1004−
1005−`a` is a [noun]().
1006−
1007−`b` is a noun.
1008−
1009−Produces
1010−--------
1011−
1012−A boolean [atom]().
1013−
1014−Source
1015−------
1016−
1017− ++ gor :: g-order
1018− ~/ %gor
1019− |= [a=* b=*]
1020− ^- ?
1021− =+ [c=(mug a) d=(mug b)]
1022− ?: =(c d)
1023− (dor a b)
1024− (lth c d)
1025−
1026−Examples
1027−--------
1028−
1029− ~zod/try=> (gor 'd' 'c')
1030− %.y
1031− ~zod/try=> 'd'
1032− 'd'
1033− ~zod/try=> 'c'
1034− ~zod/try=> `@ud`'d'
1035− 100
1036− ~zod/try=> `@ud`'c'
1037− 99
1038− ~zod/try=> (mug 'd')
1039− 1.628.185.714
1040− ~zod/try=> (mug 'c')
1041− 1.712.073.811
1042− ~zod/try=> (gor 'd' 'c')
1043− %.y
1044− ~zod/try=> (gor 'c' 'd')
1045− %.n
1046− ~zod/try=> (gor "foo" "bar")
1047− %.n
1048− ~zod/try=> (gor (some 10) (limo [1 2 3 ~]))
1049− %.n
1050−
1051−------------------------------------------------------------------------
1052−
1053−### `++hor`
1054−
1055−Hash order
1056−
1057−XX revisit
1058−
1059−Recursive hash comparator gate.
1060−
1061−Accepts
1062−-------
1063−
1064−`a` is a [noun]().
1065−
1066−`b` is a noun.
1067−
1068−Produces
1069−--------
1070−
1071−A boolean [atom]().
1072−
1073−
1074−Source
1075−------
1076−
1077− ++ hor :: h-order
1078− ~/ %hor
1079− |= [a=* b=*]
1080− ^- ?
1081− ?: ?=(@ a)
1082− ?. ?=(@ b) &
1083− (gor a b)
1084− ?: ?=(@ b) |
1085− ?: =(-.a -.b)
1086− (gor +.a +.b)
1087− (gor -.a -.b)
1088−
1089−Examples
1090−--------
1091−
1092− ~zod/try=> (hor . 1)
1093− %.n
1094− ~zod/try=> (hor 1 2)
1095− %.y
1096− ~zod/try=> (hor "abc" "cba")
1097− %.y
1098− ~zod/try=> (hor 'c' 'd')
1099− %.n
1100−
1101−------------------------------------------------------------------------
1102−
1103−### `++vor`
1104−
1105−Double hash comparator gate.
1106−
1107−XX revisit
1108−
1109−Accepts
1110−-------
1111−
1112−`a` is a [noun]()
1113−
1114−`b` is a noun
1115−
1116−Produces
1117−-------
1118−
1119−Source
1120−------
1121−
1122− ++ vor :: v-order
1123− ~/ %vor
1124− |= [a=* b=*]
1125− ^- ?
1126− =+ [c=(mug (mug a)) d=(mug (mug b))]
1127− ?: =(c d)
1128− (dor a b)
1129− (lth c d)
1130−
1131−Examples
1132−--------
1133−
1134− ~zod/try=> (vor 'f' 'g')
1135− %.y
1136− ~zod/try=> (vor 'a' 'z')
1137− %.n
1138− ~zod/try=> (vor 43.326 41.106)
1139− %.n
1140−
1141−section 2cD, insecure hashing
1142−-----------------------------
1143−
1144−### `++fnv`
1145−
1146−Hashes an atom with the 32-bit FNV non-cryptographic hash algorithm.
1147−Multiplies `a` by the prime number 16,777,619 and then takes the block
1148−of size 5 off the product's end, producing an [atom]().
1149−
1150−Accepts
1151−-------
1152−
1153−`a` is an atom.
1154−
1155−Produces
1156−--------
1157−
1158−An atom.
1159−
1160−
1161−Source
1162−------
1163−
1164− ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
1165−
1166−Examples
1167−--------
1168−
1169− ~zod/try=> (fnv 10.000)
1170− 272.465.456
1171− ~zod/try=> (fnv 10.001)
1172− 289.243.075
1173− ~zod/try=> (fnv 1)
1174− 16.777.619
1175−
1176−------------------------------------------------------------------------
1177−
1178−### `++mum`
1179−
1180−XX document
1181−
1182−Accepts
1183−-------
1184−
1185−Produces
1186−--------
1187−
1188−Source
1189−------
1190−
1191− ++ mum :: mug with murmur3
1192− ~/ %mum
1193− |= a=*
1194− |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
1195− ++ spec :: standard murmur3
1196− |= [syd=@ key=@]
1197− ?> (lte (met 5 syd) 1)
1198− =+ ^= row
1199− |= [a=@ b=@]
1200− (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b))
1201− =+ mow=|=([a=@ b=@] (end 5 1 (mul a b)))
1202− =+ len=(met 5 key)
1203− =- =. goc (mix goc len)
1204− =. goc (mix goc (rsh 4 1 goc))
1205− =. goc (mow goc 0x85eb.ca6b)
1206− =. goc (mix goc (rsh 0 13 goc))
1207− =. goc (mow goc 0xc2b2.ae35)
1208− (mix goc (rsh 4 1 goc))
1209− ^= goc
1210− =+ [inx=0 goc=syd]
1211− |- ^- @
1212− ?: =(inx len) goc
1213− =+ kop=(cut 5 [inx 1] key)
1214− =. kop (mow kop 0xcc9e.2d51)
1215− =. kop (row 15 kop)
1216− =. kop (mow kop 0x1b87.3593)
1217− =. goc (mix kop goc)
1218− =. goc (row 13 goc)
1219− =. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc)))
1220− $(inx +(inx))
1221− ::
1222− ++ trim :: 31-bit nonzero
1223− |= key=@
1224− =+ syd=0xcafe.babe
1225− |- ^- @
1226− =+ haz=(spec syd key)
1227− =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
1228− ?.(=(0 ham) ham $(syd +(syd)))
1229− --
1230− ::
1231−
1232−Examples
1233−--------
1234−
1235− ~zod/try=> (mum 10.000)
1236− 1.232.632.901
1237− ~zod/try=> (mum 10.001)
1238− 658.093.079
1239− ~zod/try=> (mum 1)
1240− 818.387.364
1241− ~zod/try=> (mum (some 10))
1242− 1.177.215.703
1243− ~zod/try=> (mum ~[1 2 3 4 5])
1244− 1.517.902.092
1245−
1246−### `++mug`
1247−
1248−Hashes `a` with the 31-bit nonzero FNV-1a non-cryptographic hash
1249−algorithm, producing an [atom]().
1250−
1251−Accepts
1252−-------
1253−
1254−A is a [noun]().
1255−
1256−Produces
1257−--------
1258−
1259−An atom.
1260−
1261−Source
1262−------
1263−
1264− ++ mug :: 31bit nonzero FNV1a
1265− ~/ %mug
1266− |= a=*
1267− ?^ a
1268− =+ b=[p=$(a -.a) q=$(a +.a)]
1269− |- ^- @
1270− =+ c=(fnv (mix p.b (fnv q.b)))
1271− =+ d=(mix (rsh 0 31 c) (end 0 31 c))
1272− ?. =(0 c) c
1273− $(q.b +(q.b))
1274− =+ b=2.166.136.261
1275− |- ^- @
1276− =+ c=b
1277− =+ [d=0 e=(met 3 a)]
1278− |- ^- @
1279− ?: =(d e)
1280− =+ f=(mix (rsh 0 31 c) (end 0 31 c))
1281− ?. =(0 f) f
1282− ^$(b +(b))
1283− $(c (fnv (mix c (cut 3 [d 1] a))), d +(d))
1284−
1285−Examples
1286−--------
1287−
1288− ~zod/try=> (mug 10.000)
1289− 178.152.889
1290− ~zod/try=> (mug 10.001)
1291− 714.838.017
1292− ~zod/try=> (mug 1)
1293− 67.918.732
1294− ~zod/try=> (mug (some 10))
1295− 1.872.403.737
1296− ~zod/try=> (mug (limo [1 2 3 4 5 ~]))
1297− 1.067.931.605
1298−
1299−section 2cE, phonetic base
1300−--------------------------
1301−
1302−### `++po`
1303−
1304−++ po
1305− ~/ %po
1306− =+ :- ^= sis :: prefix syllables
1307− 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\
1308− /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\
1309− /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\
1310− /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\
1311− /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\
1312− /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\
1313− /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\
1314− /sivtagpadsaldivdactansidfabtarmonranniswolmispal\
1315− /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\
1316− /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\
1317− /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\
1318− /havsaplindibhosdabbitbarracparloddosbortochilmac\
1319− /tomdigfilfasmithobharmighinradmashalraglagfadtop\
1320− /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\
1321− /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\
1322− /laptalpitnambonrostonfodponsovnocsorlavmatmipfap'
1323− ^= dex :: suffix syllables
1324− 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\
1325− /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\
1326− /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\
1327− /pyldulhetmevruttylwydtepbesdexsefwycburderneppur\
1328− /rysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\
1329− /secmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\
1330− /selrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\
1331− /syptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\
1332− /lytdusnebrumtynseglyxpunresredfunrevrefmectedrus\
1333− /bexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\
1334− /tenlusnussyltecmexpubrymtucfyllepdebbermughuttun\
1335− /bylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\
1336− /wedducfurfexnulluclennerlexrupnedlecrydlydfenwel\
1337− /nydhusrelrudneshesfetdesretdunlernyrsebhulryllud\
1338− /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\
1339− /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes'
1340− |%
1341−
1342−Provides the phonetic syllables and name generators for the Urbit naming
1343−system. The two faces, `sis` and `dex` are available to the arms
1344−contained in this section.
1345−
1346−------------------------------------------------------------------------
1347−
1348−### `++ind`
1349−
1350−Parse prefix
1351−
1352−Produces the byte of the right-hand syllable `a`.
1353−
1354−Accepts
1355−-------
1356−
1357−`a` is an [atom]().
1358−
1359−Produces
1360−--------
1361−
1362−A [`++unit`]() of an atom.
1363−
1364−Source
1365−------
1366−
1367− ++ ind ~/ %ind :: parse prefix
1368− |= a=@
1369− =+ b=0
1370− |- ^- (unit ,@)
1371− ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b))))
1372−
1373−Examples
1374−--------
1375−
1376− ~zod/try=> (ind:po 'zod')
1377− [~ 0]
1378− ~zod/try=> (ind:po 'zam')
1379− ~
1380− ~zod/try=> (ind:po 'del')
1381− [~ 37]
1382−
1383−------------------------------------------------------------------------
1384−
1385−### `++ins`
1386−
1387−Parse suffix
1388−
1389−Produces the byte of the left-hand phonetic syllable `b`.
1390−
1391−Accepts
1392−-------
1393−
1394−`a` is an [atom]().
1395−
1396−Produces
1397−--------
1398−A [`++unit`]() of an atom.
1399−
1400−Source
1401−------
1402−
1403− ++ ins ~/ %ins :: parse suffix
1404− |= a=@
1405− =+ b=0
1406− |- ^- (unit ,@)
1407− ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b))))
1408−
1409−Examples
1410−--------
1411−
1412− ~zod/try=> (ins:po 'mar')
1413− [~ 1]
1414− ~zod/try=> (ins:po 'son')
1415− [~ 164]
1416− ~zod/try=> (ins:po 'pit')
1417− [~ 242]
1418− ~zod/try=> (ins:po 'pok')
1419− ~
1420−
1421−------------------------------------------------------------------------
1422−
1423−### `++tod`
1424−
1425−Fetch prefix
1426−
1427−Produces the phonetic prefix syllable from index `a` within `dex` as an
1428−[atom]().
1429−
1430−Accepts
1431−-------
1432−
1433−`a` is an atom
1434−
1435−Produces
1436−--------
1437−
1438−An atom.
1439−
1440−
1441−Source
1442−------
1443−
1444− ++ tod ~/ %tod :: fetch prefix
1445− |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex)))
1446−
1447−Examples
1448−--------
1449−
1450− ~zod/try=> `@t`(tod:po 1)
1451− 'nec'
1452− ~zod/try=> `@t`(tod:po 98)
1453− 'dec'
1454− ~zod/try=> `@t`(tod:po 0)
1455− 'zod'
1456− ~zod/try=> `@t`(tod:po 150)
1457− 'ryg'
1458− ~zod/try=> `@t`(tod:po 255)
1459− 'fes'
1460− ~zod/try=> `@t`(tod:po 256)
1461− ! exit
1462−
1463−------------------------------------------------------------------------
1464−
1465−### `++tos`
1466−
1467−Fetch suffix
1468−
1469−Produces the phonetic prefix syllable from index `a` within `sis` as an
1470−[atom]().
1471−
1472−Accepts
1473−-------
1474−
1475−`a` is an atom.
1476−
1477−Produces
1478−--------
1479−
1480−An atom.
1481−
1482−Source
1483−------
1484−
1485− ++ tos ~/ %tos :: fetch suffix
1486− |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis)))
1487−
1488−Examples
1489−--------
1490−
1491− ~zod/try=> `@t`(tos:po 0)
1492− 'doz'
1493− ~zod/try=> `@t`(tos:po 120)
1494− 'fab'
1495− ~zod/try=> `@t`(tos:po 43)
1496− 'pid'
1497− ~zod/try=> `@t`(tos:po 253)
1498− 'mat'
1499−
1500−------------------------------------------------------------------------
1501−
1502−section 2cF, signed and modular ints
1503−------------------------------------
1504−
1505−### `++si`
1506−
1507− ++ si !: :: signed integer
1508− |%
1509−
1510−Container core for the signed integer functions.
1511−
1512−------------------------------------------------------------------------
1513−
1514−### `++abs`
1515−
1516−Absolute value
1517−
1518−Produces the absolute value of a signed integer.
1519−
1520−Accepts
1521−-------
1522−
1523−`a` is a signed integer, [`@s`]().
1524−
1525−Produces
1526−--------
1527−
1528−An [atom]().
1529−
1530−Source
1531−------
1532−
1533− ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value
1534−
1535−Examples
1536−--------
1537−
1538− ~zod/try=> (abs:si -2)
1539− 2
1540− ~zod/try=> (abs:si -10.000)
1541− 10.000
1542− ~zod/try=> (abs:si --2)
1543− 2
1544−
1545−------------------------------------------------------------------------
1546−
1547−### `++dif`
1548−
1549−Difference
1550−
1551−Produces the difference between two signed integers `b` and `c`.
1552−
1553−Accepts
1554−-------
1555−
1556−`a` is a signed integer, [`@s`]().
1557−
1558−`b` is a signed integer, `@s`.
1559−
1560−Produces
1561−--------
1562−
1563−A [`@s`]().
1564−
1565−
1566−Source
1567−------
1568−
1569− ++ dif |= [a=@s b=@s] :: subtraction
1570− (sum a (new !(syn b) (abs b)))
1571−
1572−Examples
1573−--------
1574−
1575− ~zod/try=> (dif:si --10 -7)
1576− --17
1577− ~zod/try=> (dif:si --10 --7)
1578− --3
1579− ~zod/try=> (dif:si `@s`0 --7)
1580− -7
1581− ~zod/try=> (dif:si `@s`0 `@s`7)
1582− --4
1583−
1584−------------------------------------------------------------------------
1585−
1586−### `++dul`
1587−
1588−Modulus
1589−
1590−Produces the modulus of two signed integers.
1591−
1592−Accepts
1593−-------
1594−
1595−`a` is a signed integer, `@s`.
1596−
1597−`b` is an [atom]().
1598−
1599−Produces
1600−--------
1601−
1602−An atom.
1603−
1604−Source
1605−------
1606−
1607− ++ dul |= [a=@s b=@] :: modulus
1608− =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c)))
1609−
1610−Examples
1611−--------
1612−
1613− ~zod/try=> (dul:si --9 3)
1614− 0
1615− ~zod/try=> (dul:si --9 4)
1616− 1
1617− ~zod/try=> (dul:si --9 5)
1618− 4
1619− ~zod/try=> (dul:si --9 6)
1620− 3
1621− ~zod/try=> (dul:si --90 --10)
1622− 10
1623−
1624−------------------------------------------------------------------------
1625−
1626−### `++fra`
1627−
1628−Divide
1629−
1630−Produces the quotient of two signed integers.
1631−
1632−Accepts
1633−-------
1634−
1635−`a` is a signed integer, [`@s`].
1636−
1637−`b` is a signed integer, `@s`.
1638−
1639−Produces
1640−--------
1641−
1642−An [atom]().
1643−
1644−Source
1645−------
1646−
1647− ++ fra |= [a=@s b=@s] :: divide
1648− (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
1649−
1650−Examples
1651−--------
1652−
1653− ~zod/try=> (fra:si --10 -2)
1654− -5
1655− ~zod/try=> (fra:si -20 -5)
1656− --4
1657−
1658−------------------------------------------------------------------------
1659−
1660−### `++new`
1661−
1662−Signed integer
1663−
1664−Produces a signed integer from a loobean sign value `a` and an [atom]() `b`.
1665−
1666−Accepts
1667−-------
1668−
1669−`a` is a loobean.
1670−
1671−`b` is an atom.
1672−
1673−Produces
1674−--------
1675−
1676−A [`@s`]()
1677−
1678−Source
1679−------
1680−
1681− ++ new |= [a=? b=@] :: [sign value] to @s
1682− `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b)))))
1683−
1684−Examples
1685−--------
1686−
1687− ~zod/try=> (new:si [& 10])
1688− --10
1689− ~zod/try=> (new:si [| 10])
1690− -10
1691− ~zod/try=> (new:si [%.y 7])
1692− --7
1693−
1694−------------------------------------------------------------------------
1695−
1696−### `++old`
1697−
1698−[sign value]
1699−
1700−Produces the cell `[sign value]` representations of a signed integer.
1701−
1702−Accepts
1703−-------
1704−
1705−`a` is a [`@s`]().
1706−
1707−Produces
1708−--------
1709−
1710−A cell of a boolean and an [atom]().
1711−
1712−Source
1713−------
1714−
1715− ++ old |=(a=@s [(syn a) (abs a)]) :: [sign value]
1716−
1717−Examples
1718−--------
1719−
1720− ~zod/try=> (old:si 7)
1721− ! type-fail
1722− ! exit
1723− ~zod/try=> (old:si -7)
1724− [%.n 7]
1725− ~zod/try=> (old:si --7)
1726− [%.y 7]
1727− ~zod/try=> (old:si `@s`7)
1728− [%.n 4]
1729− ~zod/try=> (old:si -0)
1730− [%.y 0]
1731−
1732−------------------------------------------------------------------------
1733−
1734−### `++pro`
1735−
1736−Multiply
1737−
1738−Produces the product of two signed integers.
1739−
1740−Accepts
1741−-------
1742−
1743−`a` is a [`@s`]().
1744−
1745−`b` is a `@s`.
1746−
1747−Produces
1748−--------
1749−
1750−A `@s`.
1751−
1752−Source
1753−------
1754−
1755− ++ pro |= [a=@s b=@s] :: multiplication
1756− (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
1757−
1758−Examples
1759−--------
1760−
1761− ~zod/try=> (pro:si -4 --2)
1762− -8
1763− ~zod/try=> (pro:si -4 -2)
1764− --8
1765− ~zod/try=> (pro:si --10.000.000 -10)
1766− -100.000.000
1767− ~zod/try=> (pro:si -1.337 --0)
1768− --0
1769−
1770−------------------------------------------------------------------------
1771−
1772−### `++rem`
1773−
1774−Remainder
1775−
1776−Produces the remainder from a division of two signed integers.
1777−
1778−Accepts
1779−-------
1780−
1781−`a` is a [`@s`]().
1782−
1783−`b` is a `@s`.
1784−
1785−Produces
1786−--------
1787−
1788−A `@sd`.
1789−
1790−Source
1791−------
1792−
1793− ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b)))) :: remainder
1794−
1795−Examples
1796−--------
1797−
1798− ~zod/try=> (rem:si -10 -4)
1799− -2
1800− ~zod/try=> (rem:si --10 --4)
1801− --2
1802− ~zod/try=> (rem:si --10 -4)
1803− --2
1804− ~zod/try=> (rem:si --7 --3)
1805− --1
1806− ~zod/try=> (rem:si --0 --10.000)
1807− --0
1808−
1809−------------------------------------------------------------------------
1810−
1811−### `++sum`
1812−
1813−Add
1814−
1815−Sum two signed integers.
1816−
1817−Accepts
1818−-------
1819−
1820−`b` is a [`@s`]().
1821−
1822−`c` is a signed integer `@s`.
1823−
1824−Produces
1825−--------
1826−
1827−A `@s`.
1828−
1829−Source
1830−------
1831−
1832− ++ sum |= [a=@s b=@s] :: addition
1833− ~| %si-sum
1834− =+ [c=(old a) d=(old b)]
1835− ?: -.c
1836− ?: -.d
1837− (new & (add +.c +.d))
1838− ?: (gte +.c +.d)
1839− (new & (sub +.c +.d))
1840− (new | (sub +.d +.c))
1841− ?: -.d
1842− ?: (gte +.c +.d)
1843− (new | (sub +.c +.d))
1844− (new & (sub +.d +.c))
1845− (new | (add +.c +.d))
1846−
1847−Examples
1848−--------
1849−
1850− ~zod/try=> (sum:si --10 --10)
1851− --20
1852− ~zod/try=> (sum:si --10 -0)
1853− --10
1854− ~zod/try=> (sum:si -10 -7)
1855− -17
1856− ~zod/try=> (sum:si -10 --7)
1857− -3
1858−
1859−------------------------------------------------------------------------
1860−
1861−### `++sun`
1862−
1863−Signed from unsigned
1864−
1865−Produces a signed integer from an unsigned integer.
1866−
1867−Note that the result must be manually cast to some [`@s`]() odor to be
1868−inferred as an unsigned integer in the type system.
1869−
1870−Accepts
1871−-------
1872−
1873−`a` is a [`@u`]().
1874−
1875−Produces
1876−--------
1877−
1878−A [`@s`]().
1879−
1880−Source
1881−------
1882−
1883− ++ sun |=(a=@u (mul 2 a)) :: @u to @s
1884−
1885−Examples
1886−--------
1887−
1888− ~zod/try=> `@s`10
1889− --5
1890− ~zod/try=> (sun:si 10)
1891− 20
1892− ~zod/try=> `@s`(sun:si 10)
1893− --10
1894− ~zod/try=> `@sd`(sun:si 10)
1895− --10
1896− ~zod/try=> `@sd`(sun:si 12.345)
1897− --12.345
1898−
1899−------------------------------------------------------------------------
1900−
1901−### `++syn`
1902−
1903−Sign
1904−
1905−Produce the sign of a signed integer, where `&` is posiitve, and `|` is negative.
1906−
1907−Accepts
1908−-------
1909−
1910−`a` is a [`@s`]().
1911−
1912−Produces
1913−--------
1914−
1915−A boolean.
1916−
1917−Source
1918−------
1919−
1920− ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test
1921−
1922−Examples
1923−--------
1924−
1925− ~zod/try=> (syn:si -2)
1926− %.n
1927− ~zod/try=> (syn:si --2)
1928− %.y
1929− ~zod/try=> (syn:si -0)
1930− %.y
1931−
1932−------------------------------------------------------------------------
1933−
1934−### `++cmp`
1935−
1936−Compare
1937−
1938−Compare two signed integers.
1939−
1940−Accepts
1941−-------
1942−
1943−`b` is a [`@s`]().
1944−
1945−`c` is a `@s`.
1946−
1947−Produces
1948−--------
1949−
1950−A `@s`.
1951−
1952−Source
1953−------
1954−
1955− ++ cmp |= [a=@s b=@s] :: compare
1956− ^- @s
1957− ?: =(a b)
1958− --0
1959− ?: (syn a)
1960− ?: (syn b)
1961− ?: (gth a b)
1962− --1
1963− -1
1964− --1
1965− ?: (syn b)
1966− -1
1967− ?: (gth a b)
1968− -1
1969− --1
1970−
1971−Examples
1972−--------
1973−
1974− ~zod/try=> (cmp:si --10 --10)
1975− --0
1976− ~zod/try=> (cmp:si --10 -0)
1977− --1
1978− ~zod/try=> (cmp:si -10 -7)
1979− -1
1980− ~zod/try=> (cmp:si -10 --7)
1981− -1
1982−
1983−
1984−### `++fe` :: modulo bloq
1985−
1986−Modulo bloq
1987−
1988−Core containing XX
1989−
1990−Accepts
1991−-------
1992−
1993−`a` is a [`++bloq`]().
1994−
1995−Source
1996−------
1997−
1998− |_ a=bloq
1999−
2000−### `++dif`
2001−
2002−Produces the difference between two [atom]()s in the modular basis
2003−representation.
2004−
2005−Accepts
2006−-------
2007−
2008−`a` is a [`++bloq`]().
2009−
2010−`b` is an atom.
2011−
2012−`c` is an atom.
2013−
2014−Produces
2015−--------
2016−
2017−A [`@s`]()
2018−
2019−Source
2020−------
2021−
2022− ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
2023−
2024−Examples
2025−--------
2026−
2027− ~zod/try=> (~(dif fe 3) 63 64)
2028− 255
2029− ~zod/try=> (~(dif fe 3) 5 10)
2030− 251
2031− ~zod/try=> (~(dif fe 3) 0 1)
2032− 255
2033− ~zod/try=> (~(dif fe 0) 9 10)
2034− 1
2035− ~zod/try=> (~(dif fe 0) 9 11)
2036− 0
2037− ~zod/try=> (~(dif fe 0) 9 12)
2038− 1
2039− ~zod/try=> (~(dif fe 2) 9 12)
2040− 13
2041− ~zod/try=> (~(dif fe 2) 63 64)
2042− 15
2043−
2044−------------------------------------------------------------------------
2045−
2046−### `++inv`
2047−
2048−Invert mod field
2049−
2050−Inverts the order of the modular field.
2051−
2052−Accepts
2053−-------
2054−
2055−`b` is a [`++bloq`]().
2056−
2057−Produces
2058−--------
2059−
2060−An atom.
2061−
2062−
2063−Source
2064−------
2065−
2066− ++ inv |=(b=@ (sub (dec out) (sit b)))
2067−
2068−Examples
2069−--------
2070−
2071− ~zod/try=> (~(inv fe 3) 255)
2072− 0
2073− ~zod/try=> (~(inv fe 3) 256)
2074− 255
2075− ~zod/try=> (~(inv fe 3) 0)
2076− 255
2077− ~zod/try=> (~(inv fe 3) 1)
2078− 254
2079− ~zod/try=> (~(inv fe 3) 2)
2080− 253
2081− ~zod/try=> (~(inv fe 3) 55)
2082− 200
2083−
2084−------------------------------------------------------------------------
2085−
2086−### `++net`
2087−
2088−Reverse bytes
2089−
2090−Revereses bytes within block.
2091−
2092−Accepts
2093−-------
2094−
2095−`b` is a [`++bloq`]().
2096−
2097−Produces
2098−--------
2099−
2100−An atom.=
2101−
2102−Source
2103−------
2104−
2105− ++ net |= b=@ ^- @
2106− => .(b (sit b))
2107− ?: (lte a 3)
2108− b
2109− =+ c=(dec a)
2110− %+ con
2111− (lsh c 1 $(a c, b (cut c [0 1] b)))
2112− $(a c, b (cut c [1 1] b))
2113−
2114−Examples
2115−--------
2116−
2117− ~zod/try=> (~(net fe 3) 64)
2118− 64
2119− ~zod/try=> (~(net fe 3) 128)
2120− 128
2121− ~zod/try=> (~(net fe 3) 255)
2122− 255
2123− ~zod/try=> (~(net fe 3) 256)
2124− 0
2125− ~zod/try=> (~(net fe 3) 257)
2126− 1
2127− ~zod/try=> (~(net fe 3) 500)
2128− 244
2129− ~zod/try=> (~(net fe 3) 511)
2130− 255
2131− ~zod/try=> (~(net fe 3) 512)
2132− 0
2133− ~zod/try=> (~(net fe 3) 513)
2134− 1
2135− ~zod/try=> (~(net fe 3) 0)
2136− 0
2137− ~zod/try=> (~(net fe 3) 1)
2138− 1
2139− ~zod/try=> (~(net fe 0) 1)
2140− 1
2141− ~zod/try=> (~(net fe 0) 2)
2142− 0
2143− ~zod/try=> (~(net fe 0) 3)
2144− 1
2145− ~zod/try=> (~(net fe 6) 1)
2146− 72.057.594.037.927.936
2147− ~zod/try=> (~(net fe 6) 2)
2148− 144.115.188.075.855.872
2149− ~zod/try=> (~(net fe 6) 3)
2150− 216.172.782.113.783.808
2151− ~zod/try=> (~(net fe 6) 4)
2152− 288.230.376.151.711.744
2153− ~zod/try=> (~(net fe 6) 5)
2154− 360.287.970.189.639.680
2155− ~zod/try=> (~(net fe 6) 6)
2156− 432.345.564.227.567.616
2157− ~zod/try=> (~(net fe 6) 7)
2158− 504.403.158.265.495.552
2159− ~zod/try=> (~(net fe 6) 512)
2160− 562.949.953.421.312
2161− ~zod/try=> (~(net fe 6) 513)
2162− 72.620.543.991.349.248
2163−
2164−------------------------------------------------------------------------
2165−
2166−### `++out`
2167−
2168−Max integer value
2169−
2170−The maximum integer value that the current block can store.
2171−
2172−Accepts
2173−-------
2174−
2175−A [`++bloq`]().
2176−
2177−Produces
2178−--------
2179−
2180−An [atom]().
2181−
2182−Source
2183−------
2184−
2185− ++ out (bex (bex a))
2186−
2187−Examples
2188−--------
2189−
2190− ~zod/try=> ~(out fe 0)
2191− 2
2192− ~zod/try=> ~(out fe 1)
2193− 4
2194− ~zod/try=> ~(out fe 2)
2195− 16
2196− ~zod/try=> ~(out fe 3)
2197− 256
2198− ~zod/try=> ~(out fe 4)
2199− 65.536
2200− ~zod/try=> ~(out fe 10)
2201− \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.\/
2202− 273.430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.
2203− 879.871.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.
2204− 893.424.865.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.
2205− 150.682.342.462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.
2206− 947.245.938.479.716.304.835.356.329.624.224.137.216
2207− \/ \/
2208−
2209−------------------------------------------------------------------------
2210−
2211−### `++rol`
2212−
2213−Roll left
2214−
2215−Roll `d` to the left by `c` `b`-sized blocks.
2216−
2217−Accepts
2218−-------
2219−
2220−`a` is a [`++bloq`]().
2221−
2222−`b` is a `++bloq`.
2223−
2224−`c` is an atom.
2225−
2226−`d` is an atom.
2227−
2228−Produces
2229−--------
2230−
2231−An atom.
2232−
2233−Source
2234−------
2235−
2236− ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left
2237− =+ e=(sit d)
2238− =+ f=(bex (sub a b))
2239− =+ g=(mod c f)
2240− (sit (con (lsh b g e) (rsh b (sub f g) e)))
2241−
2242−Examples
2243−--------
2244−
2245− ~zod/try=> `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
2246− 0x1213.0000.abac.dedf
2247− ~zod/try=> `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
2248− 0xdedf.1213.0000.abac
2249− ~zod/try=> `@t`(~(rol fe 5) 3 1 'dfgh')
2250− 'hdfg'
2251− ~zod/try=> `@t`(~(rol fe 5) 3 2 'dfgh')
2252− 'ghdf'
2253− ~zod/try=> `@t`(~(rol fe 5) 3 0 'dfgh')
2254− 'dfgh'
2255−
2256−------------------------------------------------------------------------
2257−
2258−### `++ror`
2259−
2260−Roll right
2261−
2262−Roll `d` to the right by `c` `b`-sized blocks.
2263−
2264−Accepts
2265−-------
2266−
2267−`a` is a [`++bloq`]().
2268−
2269−`b` is a `++bloq`.
2270−
2271−`c` is an [atom]().
2272−
2273−`d` is an atom.
2274−
2275−Produces
2276−--------
2277−
2278−An atom.
2279−
2280−Source
2281−------
2282−
2283− ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right
2284− =+ e=(sit d)
2285− =+ f=(bex (sub a b))
2286− =+ g=(mod c f)
2287− (sit (con (rsh b g e) (lsh b (sub f g) e)))
2288−
2289−Examples
2290−--------
2291−
2292− ~zod/try=> `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
2293− 0x1213.0000.abac.dedf
2294− ~zod/try=> `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
2295− 0xacde.df12.1300.00ab
2296− ~zod/try=> `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
2297− 0xdf12.1300.00ab.acde
2298− ~zod/try=> `@t`(~(rol fe 5) 3 0 'hijk')
2299− 'hijk'
2300− ~zod/try=> `@t`(~(rol fe 5) 3 1 'hijk')
2301− 'khij'
2302− ~zod/try=> `@t`(~(rol fe 5) 3 2 'hijk')
2303− 'jkhi'
2304−
23057------------------------------------------------------------------------
23068
2307−### `++sum`
2308−
2309−Sum
2310−
2311−Sum two numbers in this modular field.
2312−
2313−Accepts
2314−-------
2315−
2316−`a` is a [`++bloq`]().
2317−
2318−`b` is an [atom]().
2319−
2320−`c` is an atom.
2321−
2322−Produces
2323−--------
2324−
2325−An atom.
2326−
2327−Source
2328−------
2329−
2330− ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add
2331−
2332−Examples
2333−--------
2334−
2335− ~zod/try=> (~(sum fe 3) 10 250)
2336− 4
2337− ~zod/try=> (~(sum fe 0) 0 1)
2338− 1
2339− ~zod/try=> (~(sum fe 0) 0 2)
2340− 0
2341− ~zod/try=> (~(sum fe 2) 14 2)
2342− 0
2343− ~zod/try=> (~(sum fe 2) 14 3)
2344− 1
2345− ~zod/try=> (~(sum fe 4) 10.000 256)
2346− 10.256
2347− ~zod/try=> (~(sum fe 4) 10.000 100.000)
2348− 44.464
2349−
2350−### `++sit`
2351−
2352−Atom in mod block representation
2353−
2354−Produce an [atom]() in the current modular block representation.
2355−
2356−Accepts
2357−-------
2358−
2359−`a` is a [`++bloq`]().
2360−
2361−`b` is an atom.
2362−
2363−Produces
2364−--------
2365−
2366−An atom.
2367−
2368−Source
2369−------
2370−
2371− ++ sit |=(b=@ (end a 1 b)) :: enforce modulo
2372−
2373−Examples
2374−--------
2375−
2376− ~zod/try=> (~(sit fe 3) 255)
2377− 255
2378− ~zod/try=> (~(sit fe 3) 256)
2379− 0
2380− ~zod/try=> (~(sit fe 3) 257)
2381− 1
2382− ~zod/try=> (~(sit fe 2) 257)
2383− 1
2384− ~zod/try=> (~(sit fe 2) 10.000)
2385− 0
2386− ~zod/try=> (~(sit fe 2) 100)
2387− 4
2388− ~zod/try=> (~(sit fe 2) 19)
2389− 3
2390− ~zod/try=> (~(sit fe 2) 17)
2391− 1
2392− ~zod/try=> (~(sit fe 0) 17)
2393− 1
2394− ~zod/try=> (~(sit fe 0) 0)
2395− 0
2396− ~zod/try=> (~(sit fe 0) 1)
2397− 1
2398−
23999------------------------------------------------------------------------
240010
2401−section 2cG, floating point
2402−---------------------------
2403−
2404−XX awaiting interface rewrite
2405−
2406−section 2cH, urbit time
2407−-----------------------
2408−
2409−Note that entering '-\<-' in the shell produces the current time in @da
2410−format. We use this for many of our examples.
2411−
2412− ~zod/try=> -<-
2413− ~2014.8.4..19.39.59..9288
2414−
2415−### `++year`
2416−
2417−Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce
2418−its `@d`representation.
2419−
2420−Accepts
2421−-------
2422−
2423−`det` is a [`++date`]()
2424−
2425−Produces
2426−--------
2427−
2428−A [`@d`]().
2429−
2430−Source
2431−------
2432−
2433− ++ year :: date to @d
2434− |= det=date
2435− ^- @d
2436− =+ ^= yer
2437− ?: a.det
2438− (add 292.277.024.400 y.det)
2439− (sub 292.277.024.400 (dec y.det))
2440− =+ day=(yawn yer m.det d.t.det)
2441− (yule day h.t.det m.t.det s.t.det f.t.det)
2442−
2443−Examples
2444−--------
2445−
2446− ~zod/try=> (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]])
2447− 0x8000000d227df4e9d940000000000000
2448−
244911------------------------------------------------------------------------
245012
2451−### `++yore`
2452−
2453−Produces a `++date` from a `@d`
2454−
2455−Accepts
2456−-------
2457−
2458−`now` is a `@d`.
2459−
2460−Produces
2461−--------
2462−
2463−A [`++date`]().
2464−
2465−Source
2466−------
2467−
2468− ++ yore :: @d to date
2469− |= now=@d
2470− ^- date
2471− =+ rip=(yell now)
2472− =+ ger=(yall d.rip)
2473− :- ?: (gth y.ger 292.277.024.400)
2474− [a=& y=(sub y.ger 292.277.024.400)]
2475− [a=| y=+((sub 292.277.024.400 y.ger))]
2476− [m.ger d.ger h.rip m.rip s.rip f.rip]
2477−
2478−Examples
2479−--------
2480−
2481− ~zod/try=> (yore -<-)
2482− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=17 s=1 f=~[0x700d]]]
2483− ~zod/try=> (yore -<-)
2484− [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=28 s=53 f=~[0x7b82]]]
2485−
2486−### `++yell`
2487−
2488−Produce a parsed daily time format from an atomic date.
2489−
2490−`now` is a `@d`.
2491−
2492−Source
2493−------
2494−
2495− ++ yell :: tarp from @d
2496− |= now=@d
2497− ^- tarp
2498− =+ sec=(rsh 6 1 now)
2499− =+ ^= fan
2500− =+ [muc=4 raw=(end 6 1 now)]
2501− |- ^- (list ,@ux)
2502− ?: |(=(0 raw) =(0 muc))
2503− ~
2504− => .(muc (dec muc))
2505− [(cut 4 [muc 1] raw) $(raw (end 4 muc raw))]
2506− =+ day=(div sec day:yo)
2507− => .(sec (mod sec day:yo))
2508− =+ hor=(div sec hor:yo)
2509− => .(sec (mod sec hor:yo))
2510− =+ mit=(div sec mit:yo)
2511− => .(sec (mod sec mit:yo))
2512− [day hor mit sec fan]
2513−
2514−Examples
2515−--------
2516−
2517− ~zod/try=> (yell ~2014.3.20..05.42.53..7456)
2518− [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]]
2519− ~zod/try=> (yell ~2014.6.9..19.09.40..8b66)
2520− [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]]
2521− ~zod/try=> (yell ~1776.7.4)
2522− [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
2523−
252413------------------------------------------------------------------------
252514
2526−### `++yule`
2527−
2528−Daily time to time atom
2529−
2530−Accept a [`++tarp`](/doc/hoon/library/1#++tarp), a parsed daily time, and produces a time atom,
2531−`@d`.
2532−
2533−Accepts
2534−-------
2535−
2536−`rip` is a [`++tarp`](/doc/hoon/library/1#++tarp).
2537−
2538−Produces
2539−--------
2540−
2541−A [`@d`]().
2542−
2543−Source
2544−------
2545−
2546− ++ yule :: time atom
2547− |= rip=tarp
2548− ^- @d
2549− =+ ^= sec ;: add
2550− (mul d.rip day:yo)
2551− (mul h.rip hor:yo)
2552− (mul m.rip mit:yo)
2553− s.rip
2554− ==
2555− =+ ^= fac =+ muc=4
2556− |- ^- @
2557− ?~ f.rip
2558− 0
2559− => .(muc (dec muc))
2560− (add (lsh 4 muc i.f.rip) $(f.rip t.f.rip))
2561− (con (lsh 6 1 sec) fac)
2562−
2563−Examples
2564−--------
2565−
2566− ~zod/try=> =murica (yell ~1776.7.4)
2567− ~zod/try=> murica
2568− [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
2569− ~zod/try=> (yule murica)
2570− 0x8000000b62aaf5800000000000000000
2571− ~zod/try=> `@da`(yule murica)
2572− ~1776.7.4
2573− ~zod/try=> `@da`(yule (yell ~2014.3.20..05.42.53..7456))
2574− ~2014.3.20..05.42.53..7456
2575− ~zod/try=> `tarp`[31 12 30 0 ~]
2576− [d=31 h=12 m=30 s=0 f=~]
2577− ~zod/try=> `@dr`(yule `tarp`[31 12 30 0 ~])
2578− ~d31.h12.m30
2579−
258015------------------------------------------------------------------------
258116
2582−### `++yall`
2583−
2584−Time since beginning of time
2585−
2586−Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and
2587−day from a number of days from the beginning of time.
2588−
2589−Accepts
2590−-------
2591−
2592−`day` is a [`@ud`]()
2593−
2594−Produces
2595−--------
2596−
2597−
2598−Source
2599−------
2600−
2601− ++ yall :: day # to day of year
2602− |= day=@ud
2603− ^- [y=@ud m=@ud d=@ud]
2604− =+ [era=0 cet=0 lep=_?]
2605− => .(era (div day era:yo), day (mod day era:yo))
2606− => ^+ .
2607− ?: (lth day +(cet:yo))
2608− .(lep &, cet 0)
2609− => .(lep |, cet 1, day (sub day +(cet:yo)))
2610− .(cet (add cet (div day cet:yo)), day (mod day cet:yo))
2611− =+ yer=(add (mul 400 era) (mul 100 cet))
2612− |- ^- [y=@ud m=@ud d=@ud]
2613− =+ dis=?:(lep 366 365)
2614− ?. (lth day dis)
2615− =+ ner=+(yer)
2616− $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner)))
2617− |- ^- [y=@ud m=@ud d=@ud]
2618− =+ [mot=0 cah=?:(lep moy:yo moh:yo)]
2619− |- ^- [y=@ud m=@ud d=@ud]
2620− =+ zis=(snag mot cah)
2621− ?: (lth day zis)
2622− [yer +(mot) +(day)]
2623− $(mot +(mot), day (sub day zis))
2624−
2625−Examples
2626−--------
2627−
2628− ~zod/try=> (yall 198)
2629− [y=0 m=7 d=17]
2630− ~zod/try=> (yall 90.398)
2631− [y=247 m=7 d=3]
2632− ~zod/try=> (yall 0)
2633− [y=0 m=1 d=1]
2634−
263517------------------------------------------------------------------------
263618
2637−### `++yawn`
2638−
2639−Days since beginning of time
2640−
2641−Inverse of `yall`, computes number of days A.D. from y/m/d date as the
2642−tuple `[yer=@ud mot=@ud day=@ud]`.
2643−
2644−Accepts
2645−-------
2646−
2647−`yer` is an unsigned decimal, `@ud`.
2648−
2649−`mon` is an unsigned decimal, `@ud`.
2650−
2651−`day` is an unsigned decimal, `@ud`.
2652−
2653−Produces
2654−--------
2655−
2656−A [`@ud`]().
2657−
2658−Source
2659−------
2660−
2661− ++ yawn :: days since Jesus
2662− |= [yer=@ud mot=@ud day=@ud]
2663− ^- @ud
2664− => .(mot (dec mot), day (dec day))
2665− => ^+ .
2666− %= .
2667− day
2668− =+ cah=?:((yelp yer) moy:yo moh:yo)
2669− |- ^- @ud
2670− ?: =(0 mot)
2671− day
2672− $(mot (dec mot), cah (slag 1 cah), day (add day (snag 0 cah)))
2673− ==
2674− |- ^- @ud
2675− ?. =(0 (mod yer 4))
2676− =+ ney=(dec yer)
2677− $(yer ney, day (add day ?:((yelp ney) 366 365)))
2678− ?. =(0 (mod yer 100))
2679− =+ nef=(sub yer 4)
2680− $(yer nef, day (add day ?:((yelp nef) 1.461 1.460)))
2681− ?. =(0 (mod yer 400))
2682− =+ nec=(sub yer 100)
2683− $(yer nec, day (add day ?:((yelp nec) 36.525 36.524)))
2684− (add day (mul (div yer 400) (add 1 (mul 4 36.524))))
2685−
2686−Examples
2687−--------
2688−
2689− ~zod/try=> (yawn 2.014 8 4)
2690− 735.814
2691− ~zod/try=> (yawn 1.776 7 4)
2692− 648.856
2693− ~zod/try=> (yawn 1.990 10 11)
2694− 727.116
2695−
269619------------------------------------------------------------------------
269720
2698−### `++yelp`
2699−
2700−Leap-week?
2701−
2702−Determines whether a year contains an ISO 8601 leap week. Produces a
2703−loobean.
2704−
2705−Accepts
2706−-------
2707−
2708−`yer` is an unsigned decimal, `@ud`.
2709−
2710−Produces
2711−--------
2712−
2713−A boolean.
2714−
2715−Source
2716−------
2717−
2718− ++ yelp :: leap year
2719− |= yer=@ud ^- ?
2720− &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400))))
2721−
2722−Examples
2723−--------
2724−
2725− ~zod/try=> (yelp 2.014)
2726− %.n
2727− ~zod/try=> (yelp 2.008)
2728− %.y
2729− ~zod/try=> (yelp 0)
2730− %.y
2731− ~zod/try=> (yelp 14.011)
2732− %.n
2733−
273421------------------------------------------------------------------------
273522
2736−### `++yo`
2737−
2738− ++ yo :: time constants core
2739−
2740−Useful constants for interacting with earth time.
2741−
2742−### `++cet`
2743−
2744−Days in a century. Derived by multiplying the number of days in a year
2745−(365) by the number of years in a century (100), then adding the number
2746−days from leap years in a century (24).
2747−
2748−Produces
2749−--------
2750−
2751−An [atom]().
2752−
2753−Source
2754−------
2755−
2756− |% ++ cet 36.524 :: (add 24 (mul 100 365))
2757−
2758−Examples
2759−--------
2760−
2761− ~zod/try=> cet:yo
2762− 36.524
2763− ~zod/try=> (add 365 cet:yo)
2764− 36.889
2765− ~zod/try=> (sub (add 24 (mul 100 365)) cet:yo)
2766− 0
2767−
276823------------------------------------------------------------------------
276924
2770−### `++day`
2771−
2772−Number of seconds in a day.
2773−
2774−Produces
2775−--------
2776−
2777−An [atom]().
2778−
2779−Source
2780−------
2781−
2782− ++ day 86.400 :: (mul 24 hor)
2783−
2784−Examples
2785−--------
2786−
2787− ~zod/try=> day:yo
2788− 86.400
2789− ~zod/try=> (add 60 day:yo)
2790− 86.460
2791−
279225------------------------------------------------------------------------
279326
2794−### `++era`
2795−
2796−XX Revisit
2797−
2798−Produces
2799−--------
2800−
2801−An [atom]().
2802−
2803−Source
2804−------
2805−
2806− ++ era 146.097 :: (add 1 (mul 4 cet))
2807−
2808−Examples
2809−--------
2810−
2811−
281227------------------------------------------------------------------------
281328
2814−### `++hor`
2815−
2816−Seconds in hour
2817−
2818−The number of seconds in an hour. Derived by multiplying the number of
2819−seconds in a minute by the minutes in an hour.
2820−
2821−Produces
2822−--------
2823−
2824−An [atom]().
2825−
2826−Source
2827−------
2828−
2829− ++ hor 3.600 :: (mul 60 mit)
2830−
2831−Examples
2832−--------
2833−
2834− ~zod/try=> hor:yo
2835− 3.600
2836− ~zod/try=> (div hor:yo 60)
2837− 60
2838−
283929------------------------------------------------------------------------
284030
2841−### `++jes`
2842−
2843−XX Revisit
2844−
2845−Produces
2846−--------
2847−
2848−An atom.
2849−
2850−Source
2851−------
2852−
2853− ++ jes 106.751.991.084.417 :: (mul 730.692.561 era)
2854−
2855−Examples
2856−--------
2857−
2858− ~zod/try=> jes:yo
2859− 106.751.991.084.417
2860−
286131------------------------------------------------------------------------
286232
2863−### `++mit`
2864−
2865−Seconds in minute
2866−
2867−The number of seconds in a minute.
2868−
2869−Produces
2870−--------
2871−
2872−An [atom]().
2873−
2874−Source
2875−------
2876−
2877− ++ mit 60
2878−
2879−Examples
2880−--------
2881−
2882− ~zod/try=> mit:yo
2883− 60
2884−
288533------------------------------------------------------------------------
288634
2887−### `++moh`
2888−
2889−Days in month
2890−
2891−The days in each month of the Gregorian common year. A list of unsigned
2892−decimal atoms (Either 28, 30, or 31) denoting the number of days in the
2893−month at the year at that index.
2894−
2895−Produces
2896−--------
2897−
2898−A [`++list`]() of [`@ud`]()
2899−
2900−Source
2901−------
2902−
2903− ++ moh `(list ,@ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
2904−
2905−Examples
2906−--------
2907−
2908− ~zod/try=> moh:yo
2909− ~[31 28 31 30 31 30 31 31 30 31 30 31]
2910− ~zod/try=> (snag 4 moh:yo)
2911− 31
35+section 2cB, bit logic
36+----------------------
291237
291338------------------------------------------------------------------------
291439
2915−### `++moy`
2916−
2917−Moh with leapyear
2918−
2919−The days in each month of the Gregorian leap-year. A list of unsigned
2920−decimal atoms (Either 29,30, or 31) denoting the number of days in the
2921−month at the leap-year at that index.
40+------------------------------------------------------------------------
292241
2923−Examples
2924−--------
42+------------------------------------------------------------------------
292543
2926−A [`++list`]() of [`@ud`]()
44+------------------------------------------------------------------------
292745
2928−Source
2929−------
46+section 2cC, noun orders
47+------------------------
293048
2931− ++ moy `(list ,@ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
49+------------------------------------------------------------------------
293250
2933−Examples
2934−--------
51+------------------------------------------------------------------------
293552
2936− ~zod/try=> moy:yo
2937− ~[31 29 31 30 31 30 31 31 30 31 30 31]
2938− ~zod/try=> (snag 1 moy:yo)
2939− 29
53+------------------------------------------------------------------------
294054
294155------------------------------------------------------------------------
294256
2943−### `++qad`
57+section 2cD, insecure hashing
58+-----------------------------
294459
2945−Seconds in 4 years
60+------------------------------------------------------------------------
294661
2947−The number of seconds in four years. Derived by adding one second to the
2948−number of seconds in four years.
62+section 2cE, phonetic base
63+--------------------------
294964
2950−Produces
2951−--------
295265
2953−An [atom]().
66+section 2cF, signed and modular ints
67+------------------------------------
295468
2955−Source
2956−------
295769
2958− ++ qad 126.144.001 :: (add 1 (mul 4 yer))
70+section 2cH, urbit time
71+-----------------------
295972
2960−Examples
2961−--------
73+Note that entering '-\<-' in the shell produces the current time in @da
74+format. We use this for many of our examples.
296275
2963− ~zod/try=> qad:yo
2964− 126.144.001
76+ ~zod/try=> -<-
77+ ~2014.8.4..19.39.59..9288
296578
296679------------------------------------------------------------------------
296780
2968−### `++yer`
2969−
2970−Seconds in year
2971−
2972−The number of seconds in a year. Derived by multiplying the number of
2973−seconds in a day by 365.
2974−
2975−Produces
2976−--------
297781
2978−An [atom]().
82+------------------------------------------------------------------------
297983
2980−Source
2981−------
84+------------------------------------------------------------------------
298285
2983− ++ yer 31.536.000 :: (mul 365 day)
86+------------------------------------------------------------------------
298487
2985−Examples
2986−--------
88+------------------------------------------------------------------------
298789
2988− ~zod/try=> yer:yo
2989− 31.536.000
90+------------------------------------------------------------------------
299091
299192------------------------------------------------------------------------
299293
299394section 2cI, almost macros
299495--------------------------
299596
2996−### `++cury`
2997−
2998−Curry a gate, binding the head of its sample
2999−
3000−Accepts
3001−-------
3002−
3003−`a` is a [gate]().
3004−
3005−`b` is a [noun]().
3006−
3007−Produces
3008−--------
3009−
3010−A [gate]().
3011−
3012−Source
3013−------
3014−
3015− ++ cury
3016− |* [a=_|=(^ _*) b=*]
3017− |* c=_+<+.a
3018− (a b c)
3019−
3020−Examples
3021−--------
3022−
3023− ~zod/try=> =mol (cury add 2)
3024− ~zod/try=> (mol 4)
3025− 6
3026− ~zod/try=> (mol 7)
3027− 9
3028−
302997------------------------------------------------------------------------
303098
3031−### `++curr`
3032−
3033−Right curry
3034−
3035−Right curry a gate, binding the tail of its sample
3036−
3037−Accepts
3038−-------
3039−
3040−`a` is a [gate]().
3041−
3042−`c` is a [noun]().
3043−
3044−Produces
3045−--------
3046−
3047−
3048−Source
3049−------
3050−
3051− ++ curr
3052− |* [a=_|=(^ _*) c=*]
3053− |* b=_+<+.a
3054− (a b c)
3055−
3056−Examples
3057−--------
3058−
3059− ~zod/try=> =tep (curr scan sym)
3060− ~zod/try=> `@t`(tep "asd")
3061− 'asd'
3062− ~zod/try=> `@t`(tep "lek-om")
3063− 'lek-om'
3064−
306599------------------------------------------------------------------------
3066100
3067−### `++cork`
3068−Build `f` such that `(f x) .= (b (a x))`.
3069−
3070−`a` is a noun.
3071−
3072−`b` is a gate.
3073−
3074−Source
3075−------
3076−
3077− ++ cork |*([a=_,* b=gate] (corl b a)) :: compose forward
3078−
3079−Examples
3080−--------
3081−
3082− ~zod/try=> (:(cork dec dec dec) 20)
3083− 17
3084− ~zod/try=> =mal (mo (limo a/15 b/23 ~))
3085− ~zod/try=> ((cork ~(got by mal) dec) %a)
3086− 14
3087− ~zod/try=> ((cork ~(got by mal) dec) %b)
3088− 22
3089−
3090101------------------------------------------------------------------------
3091102
3092−### `++corl`
3093−
3094−Gate compose
3095−
3096−XX Revisit
3097−
3098−`a` is a gate.
3099−
3100−`b` is a noun.
3101−
3102−Source
3103−------
3104−
3105− ++ corl :: compose backwards
3106− |* [a=gate b=_,*]
3107− |= c=_+<.b
3108− (a (b c))
3109−
3110−Examples
3111−--------
3112−
3113− ~zod/try=> ((corl (lift bex) (slat %ud)) '2')
3114− [~ 4]
3115−
3116103------------------------------------------------------------------------
3117104
3118−### `++hard`
3119−
3120−Demands that a specific type be produced, crashing the program is it is
3121−not.
3122−
3123−Source
3124−------
3125−
3126− ++ hard
3127− |* han=$+(* *)
3128− |= fud=* ^- han
3129− ~| %hard
3130− =+ gol=(han fud)
3131− ?>(=(gol fud) gol)
3132−
3133−Examples
3134−--------
3135−
3136− ~zod/try=> ((hard (list)) (limo [1 2 3 ~]))
3137− ~[1 2 3]
3138− ~zod/try=> ((hard ,@) (add 2 2))
3139− 4
3140− ~zod/try=> ((hard ,@t) (crip "Tape to cord, bro!"))
3141− 'Tape to cord, bro'
3142− ~zod/try=> ((hard tape) (crip "...Tape to cord, bro?..."))
3143− ! hard
3144− ! exit
3145−
3146105------------------------------------------------------------------------
3147106
3148−### `++soft`
3149−
3150−Politely requests a specific type to be produced, producing null if it
3151−is not.
3152−
3153−Source
3154−------
3155−
3156− ++ soft
3157− |* han=$+(* *)
3158− |= fud=* ^- (unit han)
3159− =+ gol=(han fud)
3160− ?.(=(gol fud) ~ [~ gol])
3161−
3162−Examples
3163−--------
3164−
3165− ~zod/try=> ((soft ,%4) (add 2 2))
3166− [~ %4]
3167− ~zod/try=> ((soft ,@) (add 2 2))
3168− [~ 4]
3169− ~zod/try=> ((soft ,%5) (add 2 2))
3170− ~
3171− ~zod/try=> ((soft ,@t) (crip "Tape to cord, Woohoo!"))
3172− [~ 'Tape to cord, Woohoo!']
3173− ~zod/try=> ((soft ,@t) (trip 'Cmon man... Tape to cord? Please?!'))
3174− ~
3175−
3176107------------------------------------------------------------------------