You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -34,6 +40,8 @@ expressions are written in braces
34
40
and the last value is returned!
35
41
If I have 39 apples and I give 3 apples to everyone, i'll be left with 7.8 apples!
36
42
420
43
+
Axolotl can also do variadic functions!
44
+
Here are the remaining arguments: ["efgh","ijkl","mnop"]
37
45
```
38
46
39
47
# Syntax Guide
@@ -43,10 +51,9 @@ Files can be run using `axl` -- `axl run program.axl`
43
51
44
52
## Comments
45
53
Single line comments start with `;` and multi-line comments start and end with `#|` and `|#` respectively.
46
-
Note that as of 0.1.0.0 alpha, there's a parsing bug when a comment is the first thing in an axl file.
47
54
48
55
## Calling Functions
49
-
Since axolotl is lisp-like, functions are called using `(function-name arg1 arg2 ...)` instead of `functionName(arg1, arg2, ...)` that many other languages use.
56
+
Since axolotl is lisp-like, functions are called using `(function-name arg1 arg2 ...)` instead of `functionName(arg1, arg2, ...)`.
50
57
51
58
## Variables
52
59
Variables can be declared using the `def` function, where the first argument is the name of the variable (optionally typed) and the second argument is the value to assign to it:
@@ -57,7 +64,7 @@ Variables can be declared using the `def` function, where the first argument is
57
64
(def (name2: string) "paul") ;; creates a variable 'name2' with the value "paul"
58
65
(print name " and " name2 " are friends") ;; cody and paul are friends
59
66
```
60
-
Variables are accessible in their immediate scope **after** they are defined, and are immutable; as of 0.1.0.0 alpha there's no way to mutate them, though something is planned.
67
+
Variables are accessible in their immediate scope **after** they are defined, and are immutable; as of 0.3.0.0 alpha there's no way to mutate them, though something is planned.
61
68
62
69
## Functions
63
70
Functions can be defined using the `defun` function, where the first argument is the name of the function (optionally typed), the second argument is an array of arguments to it (which must be manually typed), and the third argument is the set of expressions to evaluate inside braces (this creates a new scope that includes all the defined variables above the function definition, and the arguments to it:
@@ -73,13 +80,20 @@ Functions can be defined using the `defun` function, where the first argument is
73
80
74
81
## Mathematical Functions
75
82
Only the operators +, -, * and / are available for now, each is a function that can take any number of arguments.
76
-
As of 0.1.0.0 alpha, there are two versions of these operators - one that returns an integer, and one that returns a float.
83
+
84
+
There are two versions of these operators - one that returns an integer, and one that returns a float.
77
85
The integer version rounds the result if it gets a float, and the float version converts to float if it gets an int.
78
86
If you want the integer version, append `i` to the function name, and if you want the float version, append `f` to the function name.
87
+
88
+
By default, if there's a float value in the arguments, the float variant will be used in case of +, -, *.
89
+
For division, the float variant will always be used by default.
90
+
79
91
For example,
80
92
```clojure
81
93
(print (+i24.95)) ;; 7
94
+
(print (+25)) ;; 7 -- since there's no float in the arguments, it automatically uses the float variant
82
95
(print (+f24.95)) ;; 6.95
96
+
(print (+24.95)) ;; 6.95 -- since there's a float in the arguments, it automatically uses the float variant
83
97
84
98
(print (-i24.95)) ;; -3
85
99
(print (-f24.95)) ;; -2.95
@@ -92,7 +106,7 @@ For example,
92
106
```
93
107
94
108
# Utility Functions
95
-
As of 0.1.0.0 alpha, there's only two utility functions - `str` and `print`
109
+
As of 0.3.0.0 alpha, there's only two utility functions - `str` and `print`
96
110
```clojure
97
111
;; str can be used to concatenate any number of arguments of any data type to form a string
98
112
;; print prints the arguments it gets to stdout with a newline
0 commit comments