list in the Julia programming language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

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. https://code.sololearn.com/c5rIiydoIfEY/?ref=app https://code.sololearn.com/c5rIiydoIfEY/?ref=app

19th Mar 2020, 6:08 PM
Bia
Bia - avatar
2 Answers
+ 3
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
19th Mar 2020, 7:51 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
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.
11th May 2020, 9:54 PM
Neur0s1s
Neur0s1s - avatar