2title = "2c: Bit Arithmetic"
10Computes the result of `2^a`, producing an atom.
49Produces an atom from a list `b` of length-value pairs `p` and `q`,
50where `p` is the length in blocks of size `a`, and `q` is an atomic
55`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
57`b` is a `list` of length-value pairs, `p` and `q`.
68 |= [a=bloq b=(list [p=@ q=@])]
71 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
77 > `@ub`21 :: @ub is the binary aura
80 > `@ub`(can 3 ~[[1 21]])
83 > `@ub`(can 3 ~[[1 1]])
86 > `@ub`(can 0 ~[[1 255]])
89 > `@ux`(can 3 [3 0xc1] [1 0xa] ~) :: @ux is the hexadecimal aura
92 > `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
95 > `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
96 0x23.000a.0000.0000.00c1
98 > `@ux`(can 3 ~[[1 'a'] [2 'bc']])
107Concatenates two atoms, `b` and `c`, according to block size `a`, producing an
112`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
128 (add (lsh a (met a b) c) b)
134 > `@ub`(cat 3 1 0) :: @ub is the binary aura
152 > `@ub`(cat 3 256 255)
153 0b1111.1111.0000.0001.0000.0000
155 > `@ub`(cat 2 256 255)
156 0b1111.1111.0001.0000.0000
170Slices `c` blocks of size `a` that are positioned `b` blocks from the end of
171`d`. That slice is produced as an atom.
175`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
192 |= [a=bloq [b=@u c=@u] d=@]
193 (end a c (rsh a b d))
205 > `@t`(cut 3 [0 3] 'abcdefgh')
208 > `@t`(cut 3 [1 3] 'abcdefgh') :: @t is the cord aura
211 > `@ub`(cut 0 [0 3] 0b1111.0000.1101) :: @ub is the binary aura
214 > `@ub`(cut 0 [0 6] 0b1111.0000.1101)
217 > `@ub`(cut 0 [4 6] 0b1111.0000.1101)
220 > `@ub`(cut 0 [3 6] 0b1111.0000.1101)
230Produces an atom by taking the last `b` blocks of size `a` from `c`.
234`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
251 (mod c (bex (mul (bex a) b)))
266 > `@ub`12 :: @ub is the binary aura
281 > `@ux`'abc' :: @ux is the hexademical aura
284 > `@ux`(end 3 2 'abc')
287 > `@t`(end 3 2 'abc') :: @t is the cord aura
297Produces an atom by repeating `c` for `b` blocks of size `a`.
301`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
321 $(d (add c (lsh a 1 d)), n +(n))
327 > `@t`(fil 3 5 %a) :: @t is the cord (string) aura
330 > `@t`(fil 5 10 %ceeb)
331 'ceebceebceebceebceebceebceebceebceebceeb'
333 > `@t`(fil 4 10 %eced)
336 > `@tas`(fil 4 10 %bf) :: @tas is the term aura
337 %bfbfbfbfbfbfbfbfbfbf
339 > `@ub`(fil 2 6 1) :: @ub is the binary aura
340 0b1.0001.0001.0001.0001.0001
349Produces an atom by left-shifting `c` by `b` blocks of size `a`.
353`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
369 (mul (bex (mul (bex a) b)) c)
375 > `@ub`1 :: @ub is the binary aura
388 0b1111.1111.0000.0000
400Computes the number of blocks of size `a` in `b`, producing an atom.
404`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
418 $(b (rsh a 1 b), c +(c))
446Concatenates a list of atoms `b` using block size `a`, producing an atom.
450`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
452`b` is a `list` of atoms.
463 |= [a=bloq b=(list @)]
473 > `@ub`(rap 2 [1 2 3 4 ~]) :: @ub is the binary aura
476 > `@ub`(rap 1 [1 2 3 4 ~])
488 > (rap 0 [0 1 0 0 1 2 ~])
500Any element of the value `0` is not included in concatenation.
507Produces an atom by assembling a list of atoms `b` using block size `a`.
511`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
513`b` is a list of atoms.
524 |= [a=bloq b=(list @)]
529 (add (lsh a c (end a 1 i.b)) $(c +(c), b t.b))
535 > `@ub`(rep 2 [1 2 3 4 ~]) :: @ub is the binary aura
541 > (rep 0 [0 0 0 1 ~])
544 > `@ub`(rep 0 [0 0 0 1 ~])
550 > (rep 0 [0 1 0 0 ~])
553 > (rep 0 [0 1 0 1 ~])
556 > (rep 0 [1 0 1 0 1 ~])
562 > `@ub`(rep 3 [12 166 8 34 ~])
563 0b10.0010.0000.1000.1010.0110.0000.1100
572Produces a list of atoms from the bits of `b` using block size `a`.
576`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
592 [(end a 1 b) $(b (rsh a 1 b))]
598 > `@ub`155 :: @ub is the binary aura
632Right-shifts `c` by `b` blocks of size `a`, producing an atom.
636`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
652 (div c (bex (mul (bex a) b)))
658 > `@ub`145 :: @ub is the binary aura
685 > `@t`(rsh 3 1 'abc')
688 > `@ux`(rsh 3 1 'abc')
698Switches little-endian to big-endian and vice versa: produces an atom by
699reversing the block order of `b` using block size `a`.
704`a` is a block size (see [`++bloq`](@/docs/reference/library/1c.md)).
715 ++ swp |=([a=bloq b=@] (rep a (flop (rip a b))))
721 > `@ub`24 :: @ub is the binary aura
743Computes the base-2 logarithm of `a`, producing an atom.
791Core that contains arms for `bloq` and modular integer operations.
806Produces the difference between two atoms in the modular basis
824 ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
830 > (~(dif fe 3) 63 64)
851 > (~(dif fe 2) 63 64)
860Inverts the order of the modular field.
864`b` is a `bloq`. (see [`++bloq`](@/docs/reference/library/1c.md))
873 ++ inv |=(b=@ (sub (dec out) (sit b)))
903Reverses bytes within a block.
907`b` is a `bloq`. (see [`++bloq`](@/docs/reference/library/1c.md))
922 (lsh c 1 $(a c, b (cut c [0 1] b)))
923 $(a c, b (cut c [1 1] b))
972 72.057.594.037.927.936
975 144.115.188.075.855.872
978 216.172.782.113.783.808
981 288.230.376.151.711.744
984 360.287.970.189.639.680
992Produces the maximum integer value that the current block can store; `2^a^a`.
1005 ++ out (bex (bex a))
1027 \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
1028 .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
1029 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
1030 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
1031 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
1032 .716.304.835.356.329.624.224.137.216
1041Rolls `d` to the left by `c` `b`-sized blocks.
1060 ++ rol |= [b=bloq c=@ d=@] ^- @
1062 =+ f=(bex (sub a b))
1064 (sit (con (lsh b g e) (rsh b (sub f g) e)))
1070 > `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
1071 0x1213.0000.abac.dedf
1073 > `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
1074 0xdedf.1213.0000.abac
1076 > `@t`(~(rol fe 5) 3 1 'dfgh')
1079 > `@t`(~(rol fe 5) 3 2 'dfgh')
1082 > `@t`(~(rol fe 5) 3 0 'dfgh')
1091Rolls `d` to the right by `c` `b`-sized blocks.
1110 ++ ror |= [b=bloq c=@ d=@] ^- @
1112 =+ f=(bex (sub a b))
1114 (sit (con (rsh b g e) (lsh b (sub f g) e)))
1120 > `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
1121 0x1213.0000.abac.dedf
1123 > `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
1124 0xacde.df12.1300.00ab
1126 > `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
1127 0xdf12.1300.00ab.acde
1129 > `@t`(~(rol fe 5) 3 0 'hijk')
1132 > `@t`(~(rol fe 5) 3 1 'hijk')
1135 > `@t`(~(rol fe 5) 3 2 'hijk')
1144Produces an atom in the current modular block representation.
1159 ++ sit |=(b=@ (end a 1 b))
1177 > (~(sit fe 2) 10.000)
1205Sums two numbers in this modular field.
1222 ++ sum |=([b=@ c=@] (sit (add b c)))
1228 > (~(sum fe 3) 10 250)
1237 > (~(sum fe 2) 14 2)
1240 > (~(sum fe 2) 14 3)
1243 > (~(sum fe 4) 10.000 256)
1246 > (~(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