Skip to content

Expression list indexing, slicing, and splatting. #330

@Paul-Ferrell

Description

@Paul-Ferrell
Collaborator

Allow list indexing and slicing.

variables: 
  foo: 
    - mod1
    - mod2
    - mod3
  nums: [1, 2, 3, 4]
  bar: '{{foo[0] + foo[-1]}}'
  baz: '{{foo[1:]}}'

  build:
    modules:
      - 'other_mod1'
      - '{{baz}}'

bar would be equal to '3'
baz would be a list of ['mod2', 'mod3'], and 'build.modules' would be ['other_mod1', 'mod2', 'mod3']

The changes is actually fairly simple; when resolving strings, allow lists of strings instead of just strings. When these are returned, if the resolved string is already part of a list, extend the whole list. It will be an error to extend a list of other structures, however, or get back anything more complex than a list of strings.

Activity

added this to the 2.3 milestone on Oct 10, 2020
self-assigned this
on Oct 10, 2020
modified the milestones: 2.3, 2.4 on Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Paul-Ferrell

      Issue actions

        Expression list indexing, slicing, and splatting. · Issue #330 · hpc/pavilion2