a=[2,7,1,8] a[1]=a[3] a[3]=a[1] a[1]+a[3]
def is_even(x) x%2 == 0 end
def tnpo (n) if is_even (n) n/2 else 3*n + 1 end end irb(main):001:0> tnpo(tnpo(tnpo(7)))
irb(main):001:0> s="abra" => "abra" irb(main):002:0> t = "cadabra" => "cadabra" irb(main):003:0> t[1..3]+s[1..2]
def sphere(r) image = make2d(2*r, 2*r) for y in 0..(2*r -1) for x in 0..(2*r -1) image[y][x] = b(r,x,y) end end image end
def inc1(b) n = b.length() for i in 0..n-1 b[i] = b[i]+1 end b end
def plus1(b) n=b.length() c=Array.new(n) for i in 0..n-1 c[i]=b[i]+1 end c end
a=[1,2,3] b=a a[2]=3 a[2]=30 b[1]=10 a
a = Array.new(2) b = Array.new(2) for i in 0..1 b[i] = a for j in 0..1 b[i][j] = i end end b
b = Array.new(2) for i in 0..1 b[i] = Array.new(2) for j in 0..1 b[i][j] = i end end b