AAVSO / VStar

VStar is a visualisation and analysis tool for variable star data brought to you by AAVSO
https://www.aavso.org/vstar
GNU Affero General Public License v3.0
9 stars 3 forks source link

Arithmetic operations over lists in VeLa #404

Closed dbenn closed 3 days ago

dbenn commented 4 months ago

There are occasions when writing VeLa code that I want simple arithmetic vector operations over 2 lists, e.g.

[1 2 3 4] - [5 6 7 8]

A variant of map that takes 2 lists as arguments would also be a useful generalisation, e.g.

map(function(n:real m:real):real{n-m} [1 2 3 4] [5 6 7 8])

or

map(λ(n:real m:real):real{n-m} [1 2 3 4] [5 6 7 8])

would yield the same result but does not provide the more pleasant syntactic sugar.

A mix of list and numeric operands should also be allowed, e.g.

2 * [5 6 7 8]
[1 2 3 4] - 42

Operations + - * / ^ should be handled.

dbenn commented 1 week ago

Currently, VeLaInterpreter.applyBinaryOperation() assumes unified types. For mixed scalar/list operations, we'll have to handle this differently.