The Sababa Programming Language

Arithmetic

Since Sababa abides to standard Lisp conventions, the mathematic methodology follows the Polish notation (Why did the Polish have to try to feel special? Creating a seemingly awkward notation). What this means is that mathematic operator (or function, variable etc. as we'll see later on) precedes the numbers, arguments, or what ever it is you're trying to evaluate. Put simply a simple expression should abide to this structure.

[operator] [integer] 

(The amount of integer you choose can vary).

or in Sababa:

sababa> + 6 7

=> 13

note: the "sababa>" is just the REPL's prompt, you don't need to manually write this out.

Our computations can gradually get more complex, by adding parenthesis, we abide to PEMDAS or (Parenthesis, Exponent, Multiplication, Division, Addition, Subtraction). Since Parenthesis comes first, expressions within a pair of parenthesis, will similarly be evaluated first. To demonstrate this, allow Sababa to make the following computations:

sababa> + 6 (- 10 2)

=> 14

In the above example, first the 10 - 2 (keep in mind the Polish notation) were accounted for, and only then the difference of the two was added to 6, to get a sum of 14.

Mathematic operators built-in with Sababa include:

Operator Mathematic Function
+ addition
- subtraction
* multiplication
/ division
^ exponent
% modulo/remainder

One final example:

sababa> + 11 (- 14 1(* 2 3))(/ 9 3)

=> 21

First the inner most parenthesis pair is accounted for, so 2 * 3 = 6. Then 14 - 1 - 6 = 7. Followed by 9 / 3 = 3. Added together to get:

11 + 7 + 3 = 21

NOTE: At the moment Sababa is restricted to using integer and long primitive types only. Therefore, float and double types will not be computed accurately, they will be rounded down. DON'T USE NUMBERS WITH A DECIMAL.