# 連番、シーケンス(sequence, range)

# Bash

arr1=`seq 1 3`

# PowerShell

1..10

# Python

nums = range(1, 4) # => [1, 2, 3]
nums = range(1, 5,  2)      # => [1, 3]
nums = range(5, 1, -1)      # => [5, 4, 3, 2]

# Ruby

nums = (1..3).to_a  # => [1, 2, 3]
nums = (1...5).to_a          # => [1, 2, 3, 4]     # 1 <= n <  5
nums = (1..5).step(2).to_a   # => [1, 3, 5]

nums = (1..5).to_a.reverse   # => [5, 4, 3, 2, 1]]

alphabets = ('a'..'z').to_a  # => ['a', 'b', .., 'z']

1.upto(5).to_a
5.downto(1).to_a
1.step(10, 2).to_a

# Swift

nums = 1...3 // => 1, 2, 3
nums = 1..<3 // => 1, 2

[ 📩 ご意見 ]