Skip to content

Support negative index for parent #313

Description

@grr

Given a path, parent currently gathers directory components starting from the bottom. From the docs: 'foo' eq path("foo/bar/baz")->parent(2);.

But if you want to get the top-most directory, you have to parse the directory yourself: '/a' eq path('/a/b/c/d/e/f/g/h/i/j')->parent(9). and you have to already know there are 9 directory components.

I propose allowing a negative index to indicate that parent should count from the top instead of the bottom: '/a' eq path('/a/b/c/d/e/f/g/h/i/j')->parent(-1).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions