Compare commits

...

3 Commits

Author SHA1 Message Date
Vaclav Tvrdik
17bdfdcbcb a bit od examples in doc 2022-12-29 14:13:56 +01:00
Vaclav Tvrdik
d9898aa64d fix erroneous paren 2022-09-12 16:05:08 +02:00
Vaclav Tvrdik
e7b62ab770 added comment for creating installation dirs 2022-09-12 16:04:48 +02:00
3 changed files with 17 additions and 9 deletions

View File

@@ -40,14 +40,14 @@
|`(set! x)`|`set!` ...|....|Language| |`(set! x)`|`set!` ...|....|Language|
## Macros ## Macros
|Signature|Description|Return values|Section| |Signature|Description|Example|Section|
|:-|-|-|-| |:-|-|-|-|
|`(unles cond body)`|`unless` only evaluates its `cond` argument. If `cond` is not truthy, then `body` is evaluated.|`>>> (unless #t (print "it is #f")) => nil`|Language| |`(unles cond body)`|`unless` only evaluates its `cond` argument. If `cond` is not truthy, then `body` is evaluated.|`>>> (unless #t (print "it is #f")) => nil`|Language|
|`(dotimes v n body)`|Iterates over `v` from 0 below `n` and evaluated `body`. Returns the last value of v|`>>> (dotimes i 5 i) => 4`|Language| |`(dotimes v n body)`|Iterates over `v` from 0 below `n` and evaluated `body`. Returns the last value of v|`>>> (dotimes i 5 i) => 4`|Language|
|`(until cond body)`|Evaluated `body` as long as `cond` is not truthy|`>>> (def i 0)(until (> i 3) (set! i (inc i))) => 4`|Language| |`(until cond body)`|Evaluated `body` as long as `cond` is not truthy|`>>> (def i 0)(until (> i 3) (set! i (inc i))) => 4`|Language|
## Library ## Library
|Signature|Description|Return values|Section| |Signature|Description|Example|Section|
|:-|-|-|-| |:-|-|-|-|
|`(= a b)`|Test whether two values are equal|`1` when equal otherwise `nil`|Language| |`(= a b)`|Test whether two values are equal|`1` when equal otherwise `nil`|Language|
|`(!= a b)`|Test whether two values are not equal|`1` when not equal otherwise `nil`|Language| |`(!= a b)`|Test whether two values are not equal|`1` when not equal otherwise `nil`|Language|
@@ -63,10 +63,10 @@
|`(list ..)`|Create a list of values||List manipulation| |`(list ..)`|Create a list of values||List manipulation|
|`(insert list index element)`|Insert an element into a list. Indexed from 0|new list with value inserted|List manipulation| |`(insert list index element)`|Insert an element into a list. Indexed from 0|new list with value inserted|List manipulation|
|`(index list index)`|Return element at index in list. First element is at index 0|Element at index|List manipulation| |`(index list index)`|Return element at index in list. First element is at index 0|Element at index|List manipulation|
|`(remove list index)`|Remove a value at an index from a list|List with element removed|List manipulation| |`(remove list index)`|Remove a value at an index from a list|`>>> (remove '(1 2 3 4) 1) => (1 3 4)`|List manipulation|
|`(len list)`|Get the length of a list|list length|List manipulation| |`(len list)`|Get the length of a list|`>>> (len '(1 2 3 4)) => 4`|List manipulation|
|`(push list element)`|Add an item to the end of a list|new list with element added|List manipulation| |`(push list element)`|Add an item to the end of a list|`>>> (push '(1 2 3 4) 5) => (1 2 3 4 5)`|List manipulation|
|`(pop list)`|Returns last element of list|Last element|List manipulation| |`(pop list)`|Returns last element of list|`>>> (pop '(1 2 3 4)) => 4`|List manipulation|
|`(head list)`|Returns first element of a list|`>>> (head '(1 2 3)) => 1`|List manipulation| |`(head list)`|Returns first element of a list|`>>> (head '(1 2 3)) => 1`|List manipulation|
|`(tail list)`|Return all elements of list except first one|`>>> (tail '(1 2 3)) => (2 3)`|List manipulation| |`(tail list)`|Return all elements of list except first one|`>>> (tail '(1 2 3)) => (2 3)`|List manipulation|
|`(first list)`|Returns first element of a list|`>>> (first '(1 2 3)) => 1`|List manipulation| |`(first list)`|Returns first element of a list|`>>> (first '(1 2 3)) => 1`|List manipulation|

View File

@@ -81,7 +81,7 @@
(def sorted (quick-sort-by scores (lambda (a b) (< (first a) (first b))))) (def sorted (quick-sort-by scores (lambda (a b) (< (first a) (first b)))))
(for e (take sorted 10) (for e (take sorted 10)
(doc::print-entry (second e)))) (doc::print-entry (second e)))
(if (> (len sorted) 10) (print "...")) (if (> (len sorted) 10) (print "..."))
)) ))

View File

@@ -8,11 +8,19 @@ echo "building ml"
cmake --build ./ --target all -j 4 -- cmake --build ./ --target all -j 4 --
echo "" echo ""
# echo "create dirs"
# sudo mkdir -p /usr/local/var/mlisp/
# sudo mkdir -p /usr/local/bin/
# sudo chown -R vaclavt:admin /usr/local/bin/
# sudo chown -R vaclavt:admin /usr/local/var/mlisp/
echo "copying lsp files" echo "copying lsp files"
mkdir -p /usr/local/var/mlisp/
cp stdlib/*.lsp /usr/local/var/mlisp/ cp stdlib/*.lsp /usr/local/var/mlisp/
echo "copying doc files" echo "copying doc files"
cp doc/*.md /usr/local/var/mlisp/ cp doc/*.md /usr/local/var/mlisp/
echo "copying ml file" echo "copying ml file"
mv ./ml /usr/local/bin/ml mv ./ml /usr/local/bin/ml