Skip to content

Commit 51ecdc7

Browse files
authored
README: bump for 0.3.0.0 alpha
1 parent ecb98a2 commit 51ecdc7

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,29 @@
88

99
(print "this is my programming language, axolotl")
1010

11-
(defun get-count [(argument-for-no-reason: int)] {
12-
(+i argument-for-no-reason 1)
11+
(defun get-given-count [(argument-for-no-reason: int)] {
12+
(+ argument-for-no-reason 1)
1313
})
1414

1515
(def text1 "If I have ")
16+
(def text2 " apples to everyone, i'll be left with ")
1617

17-
(defun arbitrary-function [(initial: int) (text2: string)] {
18+
(defun arbitrary-function [(initial: int)] {
1819
(print "expressions are written in braces")
1920
(print "and the last value is returned!")
20-
(print (str text1 (+i initial 2) " apples and I give " (get-count 2) text2 (/f (+i initial 2) (get-count 4)) " apples!"))
21+
(print (str text1 (+ initial 2) " apples and I give " (get-given-count 2) text2 (/ (+ initial 2) (get-given-count 4)) " apples!"))
2122
420
2223
})
2324

24-
(def initial 37)
25-
(def t2 " apples to everyone, i'll be left with ")
25+
(defun variadic-example [(ability: string) &(more: string)] {
26+
(print "Axolotl can also do " ability)
27+
(print "Here are the remaining arguments: " more)
28+
})
29+
30+
(def initial-val 37)
2631

27-
(print (arbitrary-function initial t2))
32+
(print (arbitrary-function initial-val))
33+
(variadic-example "variadic functions!" "abcd" "efgh" "ijkl" "mnop")
2834
```
2935
_Outputs:_
3036
```
@@ -34,6 +40,8 @@ expressions are written in braces
3440
and the last value is returned!
3541
If I have 39 apples and I give 3 apples to everyone, i'll be left with 7.8 apples!
3642
420
43+
Axolotl can also do variadic functions!
44+
Here are the remaining arguments: ["efgh","ijkl","mnop"]
3745
```
3846

3947
# Syntax Guide
@@ -43,10 +51,9 @@ Files can be run using `axl` -- `axl run program.axl`
4351

4452
## Comments
4553
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.
4754

4855
## 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, ...)`.
5057

5158
## Variables
5259
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
5764
(def (name2: string) "paul") ;; creates a variable 'name2' with the value "paul"
5865
(print name " and " name2 " are friends") ;; cody and paul are friends
5966
```
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.
6168

6269
## Functions
6370
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
7380

7481
## Mathematical Functions
7582
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.
7785
The integer version rounds the result if it gets a float, and the float version converts to float if it gets an int.
7886
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+
7991
For example,
8092
```clojure
8193
(print (+i 2 4.95)) ;; 7
94+
(print (+ 2 5)) ;; 7 -- since there's no float in the arguments, it automatically uses the float variant
8295
(print (+f 2 4.95)) ;; 6.95
96+
(print (+ 2 4.95)) ;; 6.95 -- since there's a float in the arguments, it automatically uses the float variant
8397

8498
(print (-i 2 4.95)) ;; -3
8599
(print (-f 2 4.95)) ;; -2.95
@@ -92,7 +106,7 @@ For example,
92106
```
93107

94108
# 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`
96110
```clojure
97111
;; str can be used to concatenate any number of arguments of any data type to form a string
98112
;; print prints the arguments it gets to stdout with a newline

0 commit comments

Comments
 (0)