3 title/'2c: Bit Arithmetic'
14Computes the result of `2^a`, producing an atom.
53Produces an atom from a list `b` of length-value pairs `p` and `q`,
54where `p` is the length in blocks of size `a`, and `q` is an atomic
59`a` is a block size (see [`++bloq`](../1c)).
61`b` is a `list` of length-value pairs, `p` and `q`.
72 |= [a=bloq b=(list [p=@ q=@])]
75 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
81 > `@ub`21 :: @ub is the binary aura
84 > `@ub`(can 3 ~[[1 21]])
87 > `@ub`(can 3 ~[[1 1]])
90 > `@ub`(can 0 ~[[1 255]])
93 > `@ux`(can 3 [3 0xc1] [1 0xa] ~) :: @ux is the hexadecimal aura
96 > `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
99 > `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
100 0x23.000a.0000.0000.00c1
102 > `@ux`(can 3 ~[[1 'a'] [2 'bc']])
111Concatenates two atoms, `b` and `c`, according to block size `a`, producing an
116`a` is a block size (see [`++bloq`](../1c)).
132 (add (lsh a (met a b) c) b)
138 > `@ub`(cat 3 1 0) :: @ub is the binary aura
156 > `@ub`(cat 3 256 255)
157 0b1111.1111.0000.0001.0000.0000
159 > `@ub`(cat 2 256 255)
160 0b1111.1111.0001.0000.0000
174Slices `c` blocks of size `a` that are positioned `b` blocks from the end of
175`d`. That slice is produced as an atom.
179`a` is a block size (see [`++bloq`](../1c)).
196 |= [a=bloq [b=@u c=@u] d=@]
197 (end a c (rsh a b d))
209 > `@t`(cut 3 [0 3] 'abcdefgh')
212 > `@t`(cut 3 [1 3] 'abcdefgh') :: @t is the cord aura
215 > `@ub`(cut 0 [0 3] 0b1111.0000.1101) :: @ub is the binary aura
218 > `@ub`(cut 0 [0 6] 0b1111.0000.1101)
221 > `@ub`(cut 0 [4 6] 0b1111.0000.1101)
224 > `@ub`(cut 0 [3 6] 0b1111.0000.1101)
234Produces an atom by taking the last `b` blocks of size `a` from `c`.
238`a` is a block size (see [`++bloq`](../1c)).
255 (mod c (bex (mul (bex a) b)))
270 > `@ub`12 :: @ub is the binary aura
285 > `@ux`'abc' :: @ux is the hexademical aura
288 > `@ux`(end 3 2 'abc')
291 > `@t`(end 3 2 'abc') :: @t is the cord aura
301Produces an atom by repeating `c` for `b` blocks of size `a`.
305`a` is a block size (see [`++bloq`](../1c)).
325 $(d (add c (lsh a 1 d)), n +(n))
331 > `@t`(fil 3 5 %a) :: @t is the cord (string) aura
334 > `@t`(fil 5 10 %ceeb)
335 'ceebceebceebceebceebceebceebceebceebceeb'
337 > `@t`(fil 4 10 %eced)
340 > `@tas`(fil 4 10 %bf) :: @tas is the term aura
341 %bfbfbfbfbfbfbfbfbfbf
343 > `@ub`(fil 2 6 1) :: @ub is the binary aura
344 0b1.0001.0001.0001.0001.0001
353Produces an atom by left-shifting `c` by `b` blocks of size `a`.
357`a` is a block size (see [`++bloq`](../1c)).
373 (mul (bex (mul (bex a) b)) c)
379 > `@ub`1 :: @ub is the binary aura
392 0b1111.1111.0000.0000
404Computes the number of blocks of size `a` in `b`, producing an atom.
408`a` is a block size (see [`++bloq`](../1c)).
422 $(b (rsh a 1 b), c +(c))
450Concatenates a list of atoms `b` using block size `a`, producing an atom.
454`a` is a block size (see [`++bloq`](../1c)).
456`b` is a `list` of atoms.
467 |= [a=bloq b=(list @)]
477 > `@ub`(rap 2 [1 2 3 4 ~]) :: @ub is the binary aura
480 > `@ub`(rap 1 [1 2 3 4 ~])
492 > (rap 0 [0 1 0 0 1 2 ~])
504Any element of the value `0` is not included in concatenation.
511Produces an atom by assembling a list of atoms `b` using block size `a`.
515`a` is a block size (see [`++bloq`](../1c)).
517`b` is a list of atoms.
528 |= [a=bloq b=(list @)]
533 (add (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
539 > `@ub`(rep 2 [1 2 3 4 ~]) :: @ub is the binary aura
545 > (rep 0 [0 0 0 1 ~])
548 > `@ub`(rep 0 [0 0 0 1 ~])
554 > (rep 0 [0 1 0 0 ~])
557 > (rep 0 [0 1 0 1 ~])
560 > (rep 0 [1 0 1 0 1 ~])
566 > `@ub`(rep 3 [12 166 8 34 ~])
567 0b10.0010.0000.1000.1010.0110.0000.1100
576Produces a list of atoms from the bits of `b` using block size `a`.
580`a` is a block size (see [`++bloq`](../1c)).
596 [(end a 1 b) $(b (rsh a 1 b))]
602 > `@ub`155 :: @ub is the binary aura
636Right-shifts `c` by `b` blocks of size `a`, producing an atom.
640`a` is a block size (see [`++bloq`](../1c)).
656 (div c (bex (mul (bex a) b)))
662 > `@ub`145 :: @ub is the binary aura
689 > `@t`(rsh 3 1 'abc')
692 > `@ux`(rsh 3 1 'abc')
702Switches little-endian to big-endian and vice versa: produces an atom by
703reversing the block order of `b` using block size `a`.
708`a` is a block size (see [`++bloq`](../1c)).
719 ++ swp |=([a=bloq b=@] (rep a (flop (rip a b))))
725 > `@ub`24 :: @ub is the binary aura
747Computes the base-2 logarithm of `a`, producing an atom.
795Core that contains arms for `bloq` and modular integer operations.
810Produces the difference between two atoms in the modular basis
828 ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
834 > (~(dif fe 3) 63 64)
855 > (~(dif fe 2) 63 64)
864Inverts the order of the modular field.
868`b` is a `bloq`. (see [`++bloq`](../1c))
877 ++ inv |=(b=@ (sub (dec out) (sit b)))
907Reverses bytes within a block.
911`b` is a `bloq`. (see [`++bloq`](../1c))
926 (lsh c 1 $(a c, b (cut c [0 1] b)))
927 $(a c, b (cut c [1 1] b))
976 72.057.594.037.927.936
979 144.115.188.075.855.872
982 216.172.782.113.783.808
985 288.230.376.151.711.744
988 360.287.970.189.639.680
996Produces the maximum integer value that the current block can store; `2^a^a`.
1009 ++ out (bex (bex a))
1031 \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
1032 .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
1033 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
1034 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
1035 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
1036 .716.304.835.356.329.624.224.137.216
1045Rolls `d` to the left by `c` `b`-sized blocks.
1064 ++ rol |= [b=bloq c=@ d=@] ^- @
1066 =+ f=(bex (sub a b))
1068 (sit (con (lsh b g e) (rsh b (sub f g) e)))
1074 > `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
1075 0x1213.0000.abac.dedf
1077 > `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
1078 0xdedf.1213.0000.abac
1080 > `@t`(~(rol fe 5) 3 1 'dfgh')
1083 > `@t`(~(rol fe 5) 3 2 'dfgh')
1086 > `@t`(~(rol fe 5) 3 0 'dfgh')
1095Rolls `d` to the right by `c` `b`-sized blocks.
1114 ++ ror |= [b=bloq c=@ d=@] ^- @
1116 =+ f=(bex (sub a b))
1118 (sit (con (rsh b g e) (lsh b (sub f g) e)))
1124 > `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
1125 0x1213.0000.abac.dedf
1127 > `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
1128 0xacde.df12.1300.00ab
1130 > `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
1131 0xdf12.1300.00ab.acde
1133 > `@t`(~(rol fe 5) 3 0 'hijk')
1136 > `@t`(~(rol fe 5) 3 1 'hijk')
1139 > `@t`(~(rol fe 5) 3 2 'hijk')
1148Produces an atom in the current modular block representation.
1163 ++ sit |=(b=@ (end a 1 b))
1181 > (~(sit fe 2) 10.000)
1209Sums two numbers in this modular field.
1226 ++ sum |=([b=@ c=@] (sit (add b c)))
1232 > (~(sum fe 3) 10 250)
1241 > (~(sum fe 2) 14 2)
1244 > (~(sum fe 2) 14 3)
1247 > (~(sum fe 4) 10.000 256)
1250 > (~(sum fe 4) 10.000 100.000)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list