Arc Forum
new
|
comments
|
leaders
|
submit
login
Should cut work this way?
4 points
by
garply
5225 days ago |
1 comment
(cut "ab" 0 10) throws an error, whereas I expected it to take as many characters as possible up to 10. Is there a different function that works this way? Do you think cut should work this way?
4 points
by
fallintothis
5219 days ago |
link
Arguably, no.
cut
uses
firstn
on lists, which works how you expected it to behave for strings, which is inconsistent.
arc> (firstn 10 '(a b)) (a b) arc> (cut '(a b) 0 10) (a b) arc> (cut '(a b) 200 10) nil
Of course,
cut
could just throw errors for out-of-bounds list indices, too.
-----