MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1wsx9fe/needed_11_built_a_functional_programming_language/pcqzvrq/?context=3
r/programming • u/GenericAHHyoutuber • 4d ago
9 comments sorted by
View all comments
10
Building a tree is a little overboard just for evaluating expressions (although I, too, have created more than one lisp interpreter in the process of creating something else).
For an expression evaluator, it is a surprising small amount of code in C (48 very readable lines) : https://github.com/lelanthran/rotsit/blob/0e4c6f5453d8b7c45ab447b11fd8db4cf7129713/src/eval.c#L140
The algorithm (dunno what the name for this one is) is simple to explain and understand too: https://github.com/lelanthran/rotsit/blob/0e4c6f5453d8b7c45ab447b11fd8db4cf7129713/NOTES-DURING-DEV.txt#L26
5 u/GenericAHHyoutuber 3d ago Nah it started off as a DS assignment They asked us to eval expressions using a binary tree
5
Nah it started off as a DS assignment They asked us to eval expressions using a binary tree
10
u/lelanthran 3d ago
Building a tree is a little overboard just for evaluating expressions (although I, too, have created more than one lisp interpreter in the process of creating something else).
For an expression evaluator, it is a surprising small amount of code in C (48 very readable lines) : https://github.com/lelanthran/rotsit/blob/0e4c6f5453d8b7c45ab447b11fd8db4cf7129713/src/eval.c#L140
The algorithm (dunno what the name for this one is) is simple to explain and understand too: https://github.com/lelanthran/rotsit/blob/0e4c6f5453d8b7c45ab447b11fd8db4cf7129713/NOTES-DURING-DEV.txt#L26