on 8e080d6 help sign in
51 lines 832 B history raw
1### `++cut`
3Slice
5Slices `c` blocks of size `a` that are `b` blocks from the end of `d`.
7Accepts
8-------
10`a` is a block size (see ++bloq).
12`b` is an atom.
14`c` is an atom.
16Produces
17--------
19An atom.
21Source
22------
24 ++ cut :: slice
25 ~/ %cut
26 |= {a/bloq {b/@u c/@u} d/@}
27 (end a c (rsh a b d))
29Examples
30--------
32 ~zod/try=> (cut 0 [1 1] 2)
33 1
34 ~zod/try=> (cut 0 [2 1] 4)
35 1
36 ~zod/try=> `@t`(cut 3 [0 3] 'abcdefgh')
37 'abc'
38 ~zod/try=> `@t`(cut 3 [1 3] 'abcdefgh')
39 'bcd'
40 ~zod/try=> `@ub`(cut 0 [0 3] 0b1111.0000.1101)
41 0b101
42 ~zod/try=> `@ub`(cut 0 [0 6] 0b1111.0000.1101)
43 0b1101
44 ~zod/try=> `@ub`(cut 0 [4 6] 0b1111.0000.1101)
45 0b11.0000
46 ~zod/try=> `@ub`(cut 0 [3 6] 0b1111.0000.1101)
47 0b10.0001
51***