Ruby and Lambda calculus -


i'm trying understand lambda calculus procs , ruby. here code:

puts -> x { -> y {x.call(y) } } # => #<proc:0x2a3beb0@c:/first-ruby.rb:1 (lambda)>  puts -> x { x + 2}.call(1) # => 3 

what -> signify in above example? call method passing value caller, in first example, value y passed y , in second example, 1 passed x? in second example, why 1 evaluated x?

what -> signify in above example?

-> part of literal syntax lambdas, like, say, ' part of literal syntax strings.

is .call method passing value caller,

the call method method, which, well, calls (or executes) lambda. arguments call method bound parameters of lambda.

so in first example value y passed y , in second example 1 passed x.

no, in first example, y passed outer lambda , bound x parameter. in second example, 1 passed lambda , bound x parameter.

in second example why how 1 evaluated x?

1 not evalute x. 1 immediate value, , in ruby, immediate values always evaluate themselves. 1 always evaluate 1, never x or else.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -