Skip to content

Add a function slice start end = take (end − start) . drop start? #576

@kindaro

Description

@kindaro

Many languages offer a feature that lets you take a substring by indices real quick. It is handy. Here is an example from JavaScript:

> "Hello World".slice (6, 11)
'World'

One frequent use case is when you have a parse tree annotated with locations and you want to recover the literal source of a given syntactic element. With slice, this is done at once.

Can we add such a function to text? Maybe it can have a more efficient implementation than take … . drop …?

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