subs function should count back from the end of the string when given negative offset

Description

subs function should count back from the end of the string when given negative offset.

Patch attached with test and implementation.

Environment

None

Activity

Show:
Stuart Halloway
December 31, 2010, 9:39 PM

A major strength of Clojure is consistency. If (foo X) works, then (foo Y) should work if X and Y are similar in relevant ways.

The negative offset convenience was considered and rejected when the string library was originally moved into Clojure. In order for a feature like this to be on the table, a proposal would need to include an evaluation of all API fns that take indexes, and a plan to either make all of them handle negative indexes, or have a meaningful rule about which ones do and which ones don't. If someone is interested in doing this, please begin with a motivating problem statement in the Design space.

That said, this feels very low priority.

Assignee

Unassigned

Reporter

import

Labels

None

Approval

None

Patch

Code and Test

Affects versions

Priority

Minor
Configure