Array addition and subtraction
See original GitHub issueA way to add elements to (and remove elements from) an array would be really helpful. Eg something like
Array foo = range(5) # ie [ 0, 1, 2, 3, 4 ]
Array foo2 = foo + 6 # ie [ 0, 1, 2, 3, 4, 6 ]
Array foo3 = foo2 + range(2) # ie [ 0, 1, 2, 3, 4, 6, 0, 1 ]
Array foo4 = foo3 - 1 # Question: do we remove the first, the last, or both 1's?
Array foo5 = foo4 - [4, 6] # Remove both the 4 and the 6
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:17 (13 by maintainers)
Top Results From Across the Web
Subtraction in the Array - GeeksforGeeks
Given an integer k and an array arr[], the task is to repeat the following operation exactly k times: Find the minimum non-zero...
Read more >Matrix addition & subtraction (article) | Khan Academy
Learn how to find the result of matrix addition and subtraction operations. ... we can add and subtract them much like we add...
Read more >Addition and Arrays (Grade 2) - Online Math Learning
These lessons, with videos, examples, solutions, and songs, help Grade 2 students learn how to use addition to find the total number of...
Read more >2.2.8.1: Array Addition and Subtraction - Chemistry LibreTexts
For addition and subtraction, the array operations and the matrix operations are the same, so + and - can be regarded as either...
Read more >C program to Add and Subtract of Two One Dimensional Array ...
C program to Add and Subtract of Two One Dimensional Array elements - C programming Example. This program will add and subtract two...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found some work around for people that need it :
Hope it helps.
I think these are important features. I have come across situations where concatenating two result sets was annoyingly difficult. IE spinning up a new VM for a simple echo of two separate lists. So I definitely support this.
What I would disagree with the current suggestion is how the concatenation is performed. I think the types should match, which would then make this equivalent to a python
extend
operation as opposed to an append. In this case, even single elements should be wrapped as an array. To me this looks more consistentAdditionally, I do not think that we necessarily need the corresponding binary operator
-
. most languages do not support list subtraction as a form of removal. the other reasonable option would be to have an engine function which performs this ie: