Created
September 25, 2018 13:41
-
-
Save yuyosy/bf93c9e76ec19a5176b9488515166ed8 to your computer and use it in GitHub Desktop.
Julia <loop>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 1:5 # i = 1:5と同等 1~5の範囲 | |
print("$i ") | |
end | |
println() | |
for i in 5:-1:1 # 5~1の範囲で-1ずつ変化 | |
print("$i ") | |
end | |
println() | |
# 配列を用いた繰り返し | |
a1 = [1, 2, 4, 8, 16] | |
for i in a1 | |
print("$i ") | |
end | |
println() | |
while !isempty(a1) | |
print("$(pop!(a1)) ") | |
end | |
println() | |
a2 = ["One", "Two", "Three", "Four"] | |
for i in 1:length(a2) | |
print("$i : $(a2[i]) ") # 配列の番号は1から | |
end | |
println() | |
for (i, a) in enumerate(a2) | |
print("$i : $a ") | |
end | |
println() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment