list in the Julia programming language | Sololearn: Learn to code for FREE!


list in the Julia programming language

hi guys i have a problem. Recently I started to use the Julia programming language and I came across a situation. Is it possible to create a list that stores numbers and add them all up?. I created the list but now I don't know how to add these numbers.

3/19/2020 6:08:34 PM


2 Answers

New Answer


You can use a for loop. Here is an example: sum = 0 for i in [1,2,3,4] sum += i end println(sum) Output: 10


Dicts, Tuples and Arrays are how Julia does lists. To add numbers you have to write code that iterates through an Array or Tuple. Dict is more for key-value pair.