cfunction
src/core/string.c on line 173, column 1
(string/slice bytes &opt start end)
Returns a string based on a range of a byte sequence `bytes`. The
range is specified by optional index arguments `start` and `end`
defaulting to 0 and the length of `bytes` respectively. When
non-negative, `start` is inclusive and `end` is exclusive, i.e.
[`start`, `end`), and their values can range from 0 through the
length of `bytes`. When negative, `start` is exclusive and `end` is
inclusive, i.e. (`start`, `end`], and their values can range from
the negative of one more than the length of `bytes` through -1. If
`start` or `end` is out of range, an error is raised.
(string/slice "hello" ) # => "hello"
(string/slice "hello" 0 ) # => "hello"
(string/slice "hello" 1 ) # => "ello"
(string/slice "hello" 4 ) # => "o"
(string/slice "hello" 5 ) # => ""
(string/slice "hello" -1 ) # => ""
(string/slice "hello" -2 ) # => "o"
(string/slice "hello" -5 ) # => "ello"
(string/slice "hello" -6 ) # => "hello"
(string/slice "hello" 1 1 ) # => ""
(string/slice "hello" 1 2 ) # => "e"
(string/slice "hello" 1 5 ) # => "ello"
(string/slice "hello" -5 -4 ) # => "e"
(string/slice "hello" -6 -4 ) # => "he"
(string/slice "hello" 2 1 ) # => ""
(string/slice "hello" -1 -2 ) # => ""