1

Good day, I'm a beginner in Java and I was wondering if, in Java, I'm able to do a beta reduction with a given lambda expression in Java. Basically lambda reduction is like this:
1.)
Expression : (λa.abc)x
Beta-Reduced Expression (without parenthesis) : xbc

2.) Expression :(λabc.abc)x)y)
Beta-Reduced Expression (without parenthesis) : λc.xyc

basically what I'm asking is, how do I approach this type of problem in Java? do I do it with strings, or? Just trying to learn :))

The next step would be parenthesizing, but I think it's quite complicated for me to do.

3
  • Are you asking how you can use Java8 lambda expressions like x -> x + 2? In that case, beta-reduction is just function application. Or are you trying to build a lambda calculus interpreter in Java?
    – amon
    Commented Dec 21, 2016 at 8:49
  • No sir, it's somewhat an evaluator for an actual lambda expression. Textbook stuff types.. like what's sown in the examples @amon Commented Dec 21, 2016 at 11:54
  • en.m.wikipedia.org/wiki/Symbolic_computation
    – Erik Eidt
    Commented Dec 21, 2016 at 14:59

1 Answer 1

1

You should probably parse the expression into a tree where a node can be a function applications or a lambda abstraction and then implement beta-reduction on the tree. Also implement pretty-printing the tree so you can see what is going on.

3
  • is there no other way? damn, I'll have to learn that (quite alien to me as a beginner in Programming lol) and applying it too lol. Thanks! Commented Dec 22, 2016 at 5:54
  • 1
    @SamuelDavid Well you could probably hack something together that is just string based, but it would be atrocious and not as useful a learning experience. Commented Dec 22, 2016 at 7:03
  • Sorry was having trouble with my password, I was just wondering if what you're suggesting could be able to do something like this? people.eecs.berkeley.edu/~gongliang13/lambda/#firstPage Commented Jan 7, 2017 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.