# examples of block constructs in ruby. Each can be run independently.

# raw_input = gets;               # look mom... no parens!
# value = raw_input.chomp.to_i(); # 0-arg functions can omit parentheses.
# puts value+10;

# while value > 0 do
#   puts value;
#   value = value - 1;
# end

# value = gets.chomp.to_i;

# until value <= 0 do
#   puts value
#   value = value-1;
# end

# value = 7;
# puts "--------------------"
# begin
#   print value
#   print " "
#   value = value - 1
# end until value <= 0
  

# # arrays and iterators
# # there is more than one way to do it.
# #some_ints = Array.new(10);
# some_ints = Array.new(10) { |e| e=2*e; }
# #some_ints = Array[1,2,3,4,5];
# #some_ints = Array.[](1,2,3,4,5)
# #some_ints = Array(0..9)

# # each is more or less like "ForAll" in oz, do a procedure for each elt
# # collect is more or less like "Map"
# #some_ints.each {|i| i=2*i;}
# some_ints.each do |i| puts i end
# puts "-------------------"
# puts some_ints.collect {|i| 2*i} 
# puts "-------------------"


# # Exceptions
# def foo
#   begin
#     raise 'Exception occured'
#   rescue Exception => e
#     puts e.message
#     puts e.backtrace
#   end
# end

# def bar
#   foo
# end

# bar


# jump to!
# for i in 1..4 do
#   catch (:next_i) do
#     for j in 1..4 do
#       puts "(#{i},#{j})"
#       for k in 1..10 do
#         if k > j+i then
#           print "\n"
#           puts "Exiting"
#           throw (:next_i)
#         end
#         print k
#         print " "
#       end
#       print "\n"
#     end
#   end
# end




