I can’t seem to find a way to add two arrays together. For instance is there a way to add
a = [1,2,3]
b = [4,5,6]
to get the result
c = [5,7,9]
I can’t seem to find a way to add two arrays together. For instance
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is when the arrays aren’t the same sizes:
If the second array is shorter it works. If the first array is shorter it truncates the length of the resulting array to fit. That might not be what you want.
Fixing the problem with the array-lengths changes things a little. I’d do this: