I want to make a simple, proof-of-concept application (REPL) that takes a number and then processes commands on that number.
I start with 1. Then I write "
add 2", it gives me 3. Then I write "
multiply 7", it gives me 21. Then I want to know if it is prime, so I write "
is prime" (on the current number - 21), it gives me false. "
is odd" would give me true. And so on.
Now, for a simple application with few commands, even a simple
switch would do for processing the commands. But if I want extensibility, how would I need to implement the functionality? Do I use the command pattern? Do I build a simple parser/interpreter for the language? What if I want more complex commands, like "
multiply 5 until >200" ? What would be an easy way to extend it (add new commands) without recompiling?
Edit: to clarify a few things, my end goal would not be to make something similar to WolframAlpha, but rather a list (of numbers) processor. But I want to start slowly at first (on single numbers).
I'm having in mind something similar to the way one would use Haskell to process lists, but a very simple version. I'm wondering if something like the command pattern (or equivalent) would suffice, or if I have to make a new mini-language and a parser for it to achieve my goals?
Edit2: Thanks for all the responses, all have been very helpful to me, but Emmad Kareem's helped me the most, so I'll chose it as the answer. Thanks again!