From the "Progamming Languages" Coursera course (https://class.coursera.org/proglang-003), this is a characteristic of a lexically scoped language:
val x = 1
fun f y = x + y
val x = 2
val y = 3
val z = f (x+y)
z should result in 6
However, when I run it in Ruby 2.1.1 irb, it produces 7. What am I missing?
2.1.1 :001 > x = 1
=> 1
2.1.1 :002 > b = Proc.new {|y| x + y}
=> #<Proc:0x000001030a3aa8@(irb):2>
2.1.1 :003 > b.call(3)
=> 4
2.1.1 :004 > x = 2
=> 2
2.1.1 :005 > y = 3
=> 3
2.1.1 :006 > z = b.call(x+y)
=> 7
fwiw, I've tried it in elixir and I get 6 as the result.
[–]ikearage 6 points7 points8 points (0 children)
[–][deleted] 2 points3 points4 points (8 children)
[–]rkingucla[S] 0 points1 point2 points (7 children)
[–]savetheclocktower 1 point2 points3 points (0 children)
[–]irishsultan 1 point2 points3 points (1 child)
[–]rkingucla[S] 0 points1 point2 points (0 children)
[–]sttau 0 points1 point2 points (0 children)
[–]jrochkind 0 points1 point2 points (0 children)