JanetDocsPlaygroundI'm feeling luckyGitHub sign in

buffer/slice



    cfunction
    src/core/buffer.c on line 334, column 1

    (buffer/slice bytes &opt start end)

    Takes a slice of a byte sequence from `start` to `end`. The range 
    is half open, [start, end). Indexes can also be negative, 
    indicating indexing from the end of the end of the array. By 
    default, `start` is 0 and `end` is the length of the buffer. 
    Returns a new buffer.


1 exampleSign in to add an example
Loading...
Example usage


janet:1:> (def buf @"ABCDE")
@"ABCDE"
janet:2:> (buffer/slice 0)
error: bad slot #0, expected string|symbol|keyword|buffer, got 0
  in buffer/slice
  in _thunk [repl] (tailcall) on line 2, column 1
janet:3:> (buffer/slice buf 0)
@"ABCDE"
janet:4:> (buffer/slice buf 0 1)
@"A"
janet:5:> (buffer/slice buf 0 -1)
@"ABCDE"
janet:6:> (buffer/slice buf 1 3)
@"BC"
roobiePlayground