Simple question here for Clojure. Which is more idiomatic when dealing with strings? Which is more idiomatic when dealing with other data types? Which is more efficient?
(drop 1 str)
or
(rest str)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Whatever you’re dealing with,
restwill be more efficient, but the difference will be so trivial as to be uninteresting.Make sure you know whether you want
restornext, because in some cases it matters.restis lazier, and is probably right more often, but if you userestwhen you neednextthe results can be hard to track down.For strings…neither! Use
subs, the built-in substring operator:restis fine, but it would yield a seq of characters instead of a string; usually you’ll find a string easier to deal with, and it’s simple enough to turn it back into a seq of characters sometime later.