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.
1 Answer 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.
-
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– Samuel David2016年12月22日 05:54:22 +00:00Commented 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.DepressedDaniel– DepressedDaniel2016年12月22日 07:03:33 +00:00Commented 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/#firstPageSamuel David– Samuel David2017年01月07日 13:42:34 +00:00Commented Jan 7, 2017 at 13:42
x -> x + 2
? In that case, beta-reduction is just function application. Or are you trying to build a lambda calculus interpreter in Java?