lambda-calculus

Can this be expressed in point free style?

天大地大妈咪最大 提交于 2019-11-29 11:18:52
Given the following expression to sum an IEnumerable of numbers: let sum l = l |> Seq.reduce(+) //version a is it possible to eliminate the argument--like so? let sum = Seq.reduce(+) //version b I get an error from the F# compiler (FS0030) and I seem to recall having seen something about an "eta conversion" being involved but unfortunately my knowledge of lambda calc is too limited to follow how eta conversion is involved. Can the argument be eliminated as in version b? Would someone please point me to literature that would explain an eta conversion and how it would come into play in this

Python: nested lambdas — `s_push: parser stack overflow Memory Error`

寵の児 提交于 2019-11-29 07:33:04
I recently stumbled across this article which describes how to code FizzBuzz using only Procs in Ruby, and since I was bored, thought it would be neat to try and implement the same thing in Python using lambdas. I got to the section where you create numbers using nested functions, and wrote the following Python script: #!/usr/bin/env python zero = lambda p : (lambda x: x) one = lambda p : (lambda x: p(x)) two = lambda p : (lambda x: p(p(x))) three = lambda p : (lambda x: p(p(p(x)))) five = lambda p: (lambda x: p(p(p(p(p(x)))))) fifteen = lambda p : (lambda x: p(p(p(p(p( \ p(p(p(p(p( \ p(p(p(p

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

爱⌒轻易说出口 提交于 2019-11-29 00:06:14
问题 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? 回答1: Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus? Yes, but only roughly. In the "pure" untyped lambda calculus, everything is

Subtraction operation using only increment, loop, assign, zero

孤街浪徒 提交于 2019-11-28 23:12:58
问题 I am trying to build up subtraction, addition, division, multiplication and other operations using only following ones: incr(x) - Once this function is called it will assign x + 1 to x assign(x, y) - This function will assign the value of y to x (x = y) zero(x) - This function will assign 0 to x (x = 0) loop X { } - operations written within brackets will be executed X times Using following rules it is straight forward to implement addition (add) like this: ADD (x, y) { loop X { y = incr (y)

Lambda Calculus reduction

岁酱吖の 提交于 2019-11-28 20:31:28
问题 All, Below is the lambda expression which I am finding difficult to reduce i.e. I am not able to understand how to go about this problem. (λm λn λa λb . m (n a b) b) (λ f x. x) (λ f x. f x) This is what I tried, but I am stuck: Considering the above expression as : (λm.E) M equates to E= (λn λa λb. m (n a b) b) M = (λf x. x)(λ f x. f x) => (λn λa λb. (λ f x. x) (λ f x. f x) (n a b) b) Considering the above expression as (λn. E)M equates to E = (λa λb. (λ f x. x) (λ f x. f x) (n a b) b) M = ??

What is meant by “Capture-avoiding substitutions”?

梦想与她 提交于 2019-11-28 19:46:02
问题 While reading the Lambda Calculus in Wiki, came across the term Capture-avoiding substitutions . Can someone please explain what it means as I couldn't find a definition from anywhere. Thanks PS What I want to know is the reason for telling that operation Capture-avoiding substitutions . It would be a great help if anyone can do that 回答1: Normally, the specific variable names that we chose in the lambda calculus are meaningless - a function of x is the same thing as a function of a or b or c

Can this be expressed in point free style?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 04:55:27
问题 Given the following expression to sum an IEnumerable of numbers: let sum l = l |> Seq.reduce(+) //version a is it possible to eliminate the argument--like so? let sum = Seq.reduce(+) //version b I get an error from the F# compiler (FS0030) and I seem to recall having seen something about an "eta conversion" being involved but unfortunately my knowledge of lambda calc is too limited to follow how eta conversion is involved. Can the argument be eliminated as in version b? Would someone please

What is call/cc?

拥有回忆 提交于 2019-11-28 03:23:20
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 randez-vous with Erlang. However still, I can't wrap my head around call/cc. temoto Look, i've found this Continuation Passing Style best description on this topic. Here's stripped of details copy of that article: Author: Marijn Haverbeke Date: July 24th 2007

Python: nested lambdas — `s_push: parser stack overflow Memory Error`

♀尐吖头ヾ 提交于 2019-11-28 01:34:27
问题 I recently stumbled across this article which describes how to code FizzBuzz using only Procs in Ruby, and since I was bored, thought it would be neat to try and implement the same thing in Python using lambdas. I got to the section where you create numbers using nested functions, and wrote the following Python script: #!/usr/bin/env python zero = lambda p : (lambda x: x) one = lambda p : (lambda x: p(x)) two = lambda p : (lambda x: p(p(x))) three = lambda p : (lambda x: p(p(p(x)))) five =

What is call/cc?

我与影子孤独终老i 提交于 2019-11-27 05:07:16
问题 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 randez-vous with Erlang. However still, I can't wrap my head around call/cc. 回答1: Look, i've found this Continuation Passing Style best description on this topic