lambda_calculus | dependency implementation of the untyped lambda calculus | Dashboard library
kandi X-RAY | lambda_calculus Summary
kandi X-RAY | lambda_calculus Summary
lambda_calculus is a simple, zero-dependency implementation of pure lambda calculus in Safe Rust.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lambda_calculus
lambda_calculus Key Features
lambda_calculus Examples and Code Snippets
use lambda_calculus::*;
use lambda_calculus::data::num::church::pred;
fn main() {
let mut expr = app!(pred(), 1.into_church());
println!("{} order β-reduction steps for PRED 1 are:", NOR);
println!("{}", expr);
while expr.reduce(NO
use lambda_calculus::*;
fn main() {
println!("comparing different encodings of number 3 (De Bruijn indices):");
println!(" Church encoding: {:?}", 3.into_church());
println!(" Scott encoding: {:?}", 3.into_scott());
println!(" Par
use lambda_calculus::*;
use lambda_calculus::data::num::church::fac;
fn main() {
let expr = app(fac(), 3.into_church());
println!("comparing normalizing orders' reduction step count for FAC 3:");
for &order in [NOR, APP, HNO, HAP].i
Community Discussions
Trending Discussions on lambda_calculus
QUESTION
I'm trying to understand how recursive set operate internally by comparing similar feature in another functional programming languages and concepts.
I can find it in wiki. In that, I need to know Y combinator, fixed point. I can get it briefly in wiki.
Then, now I start to apply this in Haskell.
HaskellIt is easy. But I want to know behind the scenes.
...ANSWER
Answered 2020-Dec-05 at 13:54I guess several things by myself.
- In eagar evaluation language, I must declare before use it. So the order of declaration is simple.
QUESTION
I am wondering, is any nice way (if it is possible at all) to implement an alpha-equivalence comparison in Java-8?
Obviously these two lambda-s are alpha-equivalent. Let us suppose that for some circumstances we want to detect this fact. How it can be achieved?
...ANSWER
Answered 2017-Jun-28 at 13:18I'm going out on a limb with this answer, but it may be worth mentioning this:
There is no way to do this. As Brian Goetz pointed out in an answer to a related question, there are no specified, reliable ways of obtaining the "contents" of a lambda, in that sense.
But (and now comes the vague, handwaving part) :
There is no way to do this yet.
It might be possible to do this in the future. Maybe not with Java 9, but later. The Project Panama has ambituous goals, among them, giving the developer a deeper access to lambdas, aiding in further (runtime) optimizations, translations and processing.
And recently, Radosław Smogura posted in the mailing list :
I try to capture lambda expression to get them as expression tree during runtime. I’m able to do it for simple lambdas like (o) -> (var == var) && ((varX == varX) && (someField + 1 == 1)), so later user can use (missing) API to examine tree.
Right now tree can be accessed with code like this:
QUESTION
Hello there !
I will start by giving a short, simplified definition of λ-expressions.
A λ-expression can be either :
- A variable (here, let's say it's a lower-case letter
[a-z]
) (or any simple operation with variables (likea*b
or(a+b)*c
)) - A function (or abstraction). It has the following syntax :
(λx.e)
where x is a dummy variable (can be any lower-case letter) and e is a λ-expression (eventually containingx
s). It can be read as :function λ : x -> e(x)
- A function application. It has the following syntax :
(f e)
(note that I want the space and both parenthesis) where f and e are both λ-expressions. It can be read as :f(e)
. The reduction operation basically means evaluatingf(e)
Here is a link if you want to know more about Lambda Calculus
Now, I am trying to find a regex that does a reduction operation on a function application. In other words, in the abstraction, I want to replace each dummy variable (except the one preceding the .
) by the following expression and give the resulting expression.
Here are some examples :
(For typing purpose, let's replace λ
by \
in the string)
string
=> result after one reduction
((\x.x) a)
=> a
((\x.x) (\y.y))
=> (\y.y)
(((\x.(\y.x+y)) a) b)
=> ((\y.a+y) b)
((\y.a+y) b)
=> a+b
((\x.x) (f g))
=> (f g)
((\x.x) ((\y.y) a))
=> ((\x.x) a)
OR ((\y.y) a)
(depends on what you think is easier to do. My guess would be the first one)
It can be done with multiple substitutions, but I would prefer no more than 2.
The language I am using is Powershell, so the regex must support .NET flavour (it does mean that recursion is not allowed...)
I am pretty sure there is something to do with balancing groups, but I can't find a working regex...
Also, there certainly are better solutions than using regex, but I want to do that with regex, no code here.
I will add more examples when I think of good ones.
Edit 1 :
All I managed to do so far is matching the expression and capture each sub-expression with the following regex :
ANSWER
Answered 2017-May-24 at 15:58Ok I figured it out. It's a pretty long regex, so try to understand it at your own risk ;)
Here it goes :
QUESTION
Say this is my program:
...ANSWER
Answered 2017-May-22 at 18:32Is the substitution model a good way of approximating how JavaScript evaluates pure code?
Of course !
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lambda_calculus
backslash_lambda: changes the display of lambdas from λ to \
encoding: builds the data encoding modules; default feature
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page