lambda-calculus

Lambda Calculus Reduction steps

こ雲淡風輕ζ 提交于 2019-12-03 01:54:29
问题 I am studying Lambda Calculus and I am stuck at Reduction.... Can anyone explain the types of reduction with this example, especially beta reduction in the simplest way possible. Also wouldn't mind an easy to understand tutorial. (λxyz .xyz )(λx .xx )(λx .x )x 回答1: Lambda calculus Lambda calculus has a way of spiraling into a lot of steps, making solving problems tedious, and it can look real hard, but it isn't actually that bad. In lambda calculus, there are only lambdas, and all you can do

Embedding higher kinded types (monads!) into the untyped lambda calculus

↘锁芯ラ 提交于 2019-12-03 00:31:20
It's possible to encode various types in the untyped lambda calculus through higher order functions. Examples: zero = λfx. x one = λfx. fx two = λfx. f(fx) three = λfx. f(f(fx)) etc true = λtf. t false = λtf. f tuple = λxyb. b x y null = λp. p (λxy. false) I was wondering if any research has gone into embedding other less conventional types. It would be brilliant if there is some theorem which asserts that any type can be embedded. Maybe there are restrictions, for example only types of kind * can be embedded. If it is indeed possible to represent less conventional types, it would be awesome

Is it possible to evaluate lambda calculus terms efficiently?

痞子三分冷 提交于 2019-12-02 23:42:04
I've been writing a lot of programs in the lambda calculus recently and I wish I could run some of them in realtime. Yet, as much as the trending functional paradigm is based on the lambda calculus and the rule of B-reductions, I couldn't find a single evaluator that isn't a toy, not meant for efficiency. Functional languages are supposed to be fast, but those I know don't actually provide access to normal forms (see Haskell's lazy evaluator, Scheme's closures and so on), so don't work as LC evaluators. That makes me wonder: is it just impossible to evaluate lambda calculus terms efficiently,

Calling/applying lambda vs. function call - the syntax in Ruby is different. Why?

爷,独闯天下 提交于 2019-12-02 17:59:11
I am kinda new to Ruby and still trying to understand some of the language design principles. IF I've got it right, the lambda expression call in Ruby must be with square braces, while the "regular" function call is with "regular"/round braces. Is there a special reason that the syntax is different? Or, in other words, (why) should the caller be aware whether they call a function or apply a lambda expression? Because in Ruby, methods are not lambdas (like, for example, in JavaScript). Methods always belong to objects, can be inherited (by sub-classing or mixins), can be overwritten in an

Lambda Calculus Reduction steps

烂漫一生 提交于 2019-12-02 14:08:40
I am studying Lambda Calculus and I am stuck at Reduction.... Can anyone explain the types of reduction with this example, especially beta reduction in the simplest way possible. Also wouldn't mind an easy to understand tutorial. (λxyz .xyz )(λx .xx )(λx .x )x rp.beltran Lambda calculus Lambda calculus has a way of spiraling into a lot of steps, making solving problems tedious, and it can look real hard, but it isn't actually that bad. In lambda calculus, there are only lambdas, and all you can do with them is substitution. Lambdas are like a function or a method - if you are familiar with

Why is Haskell (GHC) so darn fast?

放肆的年华 提交于 2019-12-02 13:47:00
Haskell (with the GHC compiler) is a lot faster than you'd expect . Used correctly, it can get close-ish to low-level languages. (A favorite thing for Haskellers to do is to try and get within 5% of C (or even beat it, but that means you are using an inefficient C program, since GHC compiles Haskell to C).) My question is, why? Haskell is declarative and based on lambda calculus. Machine architectures are clearly imperative, being based on turing machines, roughly. Indeed, Haskell doesn't even have a specific evaluation order. Also, instead of dealing with machine data types, you make

END OF FILE token with flex and bison (only works without it)

走远了吗. 提交于 2019-12-02 10:12:55
问题 OK this is kind of an odd question because what I have here works the way I want it to. What I'm doing is writing a parser for a lambda calculus expression. So an expression can be one of four things: variable constant (expression expression) (lambda variable.expression) Now as you can see, the last two expressions have expressions within them. What I was trying to do was determine the overall expression so I can report which type it is. So for example the expression ((lambda x.(f1 x)) 100)

What are the correct semantics of a closure over a loop variable? [closed]

走远了吗. 提交于 2019-12-02 09:25:28
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Consider the following lua code: f = {} for i = 1, 10 do f[i] = function() print(i .. " ") end end for k = 1, 10 do f[k]() end This

END OF FILE token with flex and bison (only works without it)

我们两清 提交于 2019-12-02 06:14:25
OK this is kind of an odd question because what I have here works the way I want it to. What I'm doing is writing a parser for a lambda calculus expression. So an expression can be one of four things: variable constant (expression expression) (lambda variable.expression) Now as you can see, the last two expressions have expressions within them. What I was trying to do was determine the overall expression so I can report which type it is. So for example the expression ((lambda x.(f1 x)) 100) is a combination overall. My idea was to return an END token from flex when it reached the end of file.

What are the correct semantics of a closure over a loop variable? [closed]

こ雲淡風輕ζ 提交于 2019-12-02 04:28:05
Consider the following lua code: f = {} for i = 1, 10 do f[i] = function() print(i .. " ") end end for k = 1, 10 do f[k]() end This prints the numbers from 1 to 10. In this case, i is closed over the value for each iteration of the outer loop. This is how I had always understood closures, and I was very happy... ...until I was porting some lua code into c#, and I tried to do the same thing: var f = new Action[10]; for (int i = 0; i < 10; i++) { f[i] = (new Action(delegate() { Console.Write(i + " "); })); } for (int k = 0; k < 10; k++) { f[k](); } And now I get the number 10 printed 10 times