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.

  • 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 Dec 21 '16 at 08:49
  • No sir, it's somewhat an evaluator for an actual lambda expression. Textbook stuff types.. like what's sown in the examples @amon – Samuel David Dec 21 '16 at 11:54
  • https://en.m.wikipedia.org/wiki/Symbolic_computation – Erik Eidt Dec 21 '16 at 14:59

1 Answers1

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.

DepressedDaniel
  • 936
  • 5
  • 6
  • 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! – Samuel David Dec 22 '16 at 05: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. – DepressedDaniel Dec 22 '16 at 07: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? https://people.eecs.berkeley.edu/~gongliang13/lambda/#firstPage – Samuel David Jan 07 '17 at 13:42