a bit od examples in doc

This commit is contained in:
Vaclav Tvrdik 2022-12-29 14:13:56 +01:00
parent d9898aa64d
commit 17bdfdcbcb
1 changed files with 7 additions and 7 deletions

View File

@ -40,14 +40,14 @@
|`(set! x)`|`set!` ...|....|Language|
## 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|
|`(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|
## 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 not equal|`1` when not equal otherwise `nil`|Language|
@ -63,10 +63,10 @@
|`(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|
|`(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|
|`(len list)`|Get the length of a list|list length|List manipulation|
|`(push list element)`|Add an item to the end of a list|new list with element added|List manipulation|
|`(pop list)`|Returns last element of list|Last element|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|`>>> (len '(1 2 3 4)) => 4`|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|`>>> (pop '(1 2 3 4)) => 4`|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|
|`(first list)`|Returns first element of a list|`>>> (first '(1 2 3)) => 1`|List manipulation|
@ -192,4 +192,4 @@
|`(thread-sleep milisecons)`|Sleeps thread for given amount of miliseconds|`>>> (thread-sleep 100) => 100`|Threading|
|`(threads-join)`|Wait for all running threads to finish||Threading|
|`(try block catch_block [finally_block])`|Evaluates block and if an exception is thrown, evaluates catch_block.Eventually in both cases evals finally_block. Return evaluated last expression from block if no exception or last expression from catch_block, if exception is thrown from block. Variable ml-exception in catch block is available with astring describing exception||Exceptions|
|`(throw exp_desc)`|Throws an exception with exp_desc describing what happened. exp_desc will be evaluated a returned as string|`>>> (throw (+ 1 2))\n3`|Exceptions|
|`(throw exp_desc)`|Throws an exception with exp_desc describing what happened. exp_desc will be evaluated a returned as string|`>>> (throw (+ 1 2))\n3`|Exceptions|