Skip to content

Way to get the last index of a text or list #233

@Lartu

Description

@Lartu

In order to access the last element of a list or the last character of a string, you have to perform three commands:

  1. Get the length of the container.
  2. Subtract one from it to point to the last element of the container.
  3. Access the container.

The code for that looks like this:

IN index GET LENGTH OF container
DECREMENT index
IN value STORE container:index

Goes without saying that this syntax is very cumbersome, as accessing the last value of a container is something that's commonly done.

I propose a new statement:

IN index GET LAST INDEX OF container

This statement would store in index the ordinal value of the last valid index of the container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions