Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ion ion
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 84
    • Issues 84
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-os
  • ionion
  • Issues
  • #336
Closed
Open
Created Jun 22, 2017 by Michael Aaron Murphy@mmstickMaintainer

Builtin: Array Arithmetic Expressions

Now that we have support for string-based arithmetic, perhaps we might want to also implement array-based arithmetic? This issue will discuss possible syntax ideas that we could pursue.

Proposal # 1

This approach is commonly used in functional languages, so it might also be a natural fit here. Define a variable name to describe each element in the array, and then follow it with a mathematical expression to apply with each element in the array.

@[ELEMENT -> EXPR, ARRAY EXPR]

Examples

Example # 1

let array = [1 2 3]
for result in @[x -> x * x, array]
    echo $result
end

Output # 1

1
4
9

Example # 2

let array = [1 2 3]
let value = 3
for result in @[x -> x * value, array]
    echo $result
end

Output # 2

3
6
9
Edited Jun 01, 2021 by matu3ba
Assignee
Assign to
Time tracking