lambda-calculus

How helpful is knowing lambda calculus?

To all the people who know lambda calculus: What benefit has it bought you, regarding programming? Would you recommend that people learn it? ...

Primitive recursion

how will i define the function 'simplify' using primitive recursion? simplify :: Expr -> Expr ... simplify Simplify an expression using basic arithmetic, e.g. simplify (Plus (Var "x") (Const 0)) = Var "x" ...

How do I simplify the below expressions using primitive recursion ?

The simplifications I have in mind are 0*e = e*0 = 0 1*e = e*1 = 0+e = e+0 = e-0 = e and simplifying constant subexpressions, e.g. Plus (Const 1) (Const 2) would become Const 3. I would not expect variables (or variables and constants) to be concatenated: Var "st" is a distinct variable from Var "s". For example simplify(Plus (Var "...

How can I evaluate an expression?

How can I evaluate an expression, given a list of values for the variables it contains? eval::[(Variable,Integer)]->Expr->Integer Example: eval[("x",2), ("y",4)](Mult(Plus(Var "x") (Const))(Var "y"))= 12 ...

How can I write an addition of two items in a string representation?

For example I want to add two expressions e1 and e2 toString (Plus e1 e)= ?? I am guessing it would be something like toString (Plus e1 e)= ((toString e1) ++ "+" ++ (toString e2)) ...

How do I convert a variable to a string?

For example so that it works like this toString (Var x)= "x" ...

What elegant and Turing-complete machines* you know? Is there a one from The Book?

Lambda calculus of course is quite elegant, but doesn't it bother you that there is this asymmetry between input and output of a function? I.e. you can make the function take two parameters (by returning a function) but you can't make it return two values. I don't think we could find it in The Book. ...

What are some resources for learning Lambda Calculus?

So the Wikipedia entry on Lambda Calculus was interesting but I've finished it. I wish to dive a little deeper and get a better understanding of Lambda Calculus. Can anyone recommend what they consider to be the best book or primer to Lambda Calculus? ...

What is call/cc?

I've tried several times to grasp the concept of continuations and call/cc. Every single attempt was a failure. Can somebody please explain me these concepts, ideally with more realistic examples than these on Wikipedia or in other SO posts. I have background in web programming and OOP. I also understand 6502 assembly and had a minor ra...

Lambda calculus and church numerals confusion

I'm trying to understand the basics of lambda calculus and Church numerals. I have been doing a lot of reading and practising, but I seem to keep getting stuck with trying to see how some functions work. The example I am stuck on is as follows. Perhaps someone can explain where I have gone wrong. The Church numeral for 1 can be represe...

How to write an empty list using S, K and I combinators?

I know that: (cons [p] [q]) is ((s ((s i) (k [p]))) (k [q])) (car [lst]) is ([lst] k) (cdr [lst]) is ([lst] (k i)) I want to write a list like this (cons [a] (cons [b] (cons [c] [nil]))) , which is going to be something like this: ((s ((s i) (k [a]))) (k ((s ((s i) (k [b]))) (k ((s ((s i) (k [c]))) (k [nil])))))) But I don't kno...

Church Numerals: how to encode zero in lambda calculus?

I am learning lambda calculus but I cant seem to understand the encoding for the number 0. how is "function that takes in a function and a second value and applies the function zero times on the argument" a zero? Is there any other way to encode zero? Could anyone here help me encode 0? ...

Convergence of Mathematics and Programming Languages

It seems that there is a strong movement for the convergence of mathematics and computer programming languages, this is notably evidenced by the influence of the lambda calculus on modern languages. Most of the time I do not think with mathematics, I think with logic. It seems to me that many of the phenomenon that can be modeled mathema...

lambda calculus for functional programming

in lambda calculus (λ x. λ y. λ s. λ z. x s (y s z)) is used for addition of two Church numerals how can we explain this, is there any good resource the lambda calculus for functional programming ? your help is much appreciated ...

Convert Python to Haskell / Lambda calculus

What is the Python code in Haskell and Lambda calculus? def f1(): x = 77 def f2(): print x f2 f1 My attempt in lambda calculus \x. 77 (\x.x) ...

Query on Booleans in Lambda Calculus

Hi All, I have following query on lambda calculus which am not able to understand: Here is the lambda calculus representation for the AND operator: lambda(m).lambda(n).lambda (a).lambda (b). m(n a b) b Can anyone help me in understanding this representation? Regards, darkie ...

How can I make Church numerals more human readable in lisp?

I can define church numerals fairly easy using scheme: > (define f (lambda (x) x)) > (f f) ;0 #<procedure:f> > (f (f f)) ;1 #<procedure:f> However, this doesn't make it very easy to recognize that (f f) is 0 and (f (f f)) is 1. Is there a way that I can make these numerals more readable? What would be ideal is this: > (f f) 0 > (f ...

What's the formal name for this Syntax?

Sometimes in Scheme, I have functions that take arguments like this add 3 4 What do you call this kind of "list" where it's elements are like a1 a2 a3 ? I don't think you can call it a list because lists are contained in parenthesis and elements are comma-seperated. ...

What type of lambda calculus would Lisp loosely be an example of?

I'm trying to get a better grip on how types come into play in lambda calculus. Admittedly, a lot of the type theory stuff is over my head. Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Or is there some kind of "dynamically typed lambda calculus" that I'm unaware of? ...

Church numeral for addition

Hi All, I am stuck up at the following step. It will be great if someone can help me out: 2 = λfx.f(f x) 3 = λfx.f(f(f x)) ADD = λm n f x. m f (n f x) My steps are: (λm n f x. m f (n f x)) (λf x.f(f(f x))) (λf x.f(f x)) -> ((λn f x. (λf x.f(f(f x))) f (n f x))) (λf x.f(f x)) -> ((λf x. (λf' x'.f'(f'(f' x'))) f ((λf" x".f"(f" x"))...