on bfaa358 help sign in
49 lines 931 B history raw
2### `++can`
4Assemble
6Produces an atom from a list `b` of length-value pairs `p` and `q`,
7where `p` is the length in bloqs of size `a`, and `q` is an atomic
8value.
10Accepts
11-------
13`a` is a block size (see `++bloq`).
15`b` is a `++list` of length value pairs, `p` and `q`.
17Produces
18--------
20An atom.
22Source
23------
25 ++ can :: assemble
26 ~/ %can
27 |= [a/bloq b/(list [p=@ q=@])]
28 ^- @
29 ?~ b 0
30 (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
32Examples
33--------
35 ~zod/try=> `@ub`(can 3 ~[[1 1]])
36 0b1
37 ~zod/try=> `@ub`(can 0 ~[[1 255]])
38 0b1
39 ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] ~)
40 0xa00.00c1
41 ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
42 0x23.0a00.00c1
43 ~zod/try=> `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
44 0x23.000a.0000.0000.00c1
45 ~zod/try=> `@ux`(can 3 ~[[1 'a'] [2 'bc']])
46 0x63.6261
49***