diff --git a/doc/Doc.md b/doc/Doc.md index 0d10af6..f1203e4 100644 --- a/doc/Doc.md +++ b/doc/Doc.md @@ -12,7 +12,9 @@ |`(quote x)`|`quote` evaluates none of its arguments.|This is equivalent to the `'expr` syntactic sugar.| |`(for x list ...)`|`for` evaluates only its list argument.|`for` iterates through the list storing each element in `x`, and then evaluating all of the rest of the values in the `for` body. It then returns the last value evaluated.| |`(while cond ...)`|`while` evaluates only its cond argument.|`while` evaluates its condition expression every iteration before running. If it is true, it continues to evaluate every expression in the `while` body. It then returns the last value evaluated.| - +|`(and ...)`|`and` evaluates logical and on its list argument.|`and` evaluates only until its true, it stops when becomes false. +|`(or ...)`|`or` evaluates logical or on its list argument.|`or` evaluates while its false, it stops when becomes true.| +|`(benchmark msg_string ...)`|`benchmark` takes a list of s-expressions and evaluates them in the order they were given (in the current scope), and then returns the result of the last s-expression and prints msg_string and timing info.|| ## Library |Signature|Description|Return values| @@ -75,6 +77,17 @@ |`(string-replace source substr replacement)`|Replace a substring with a replacement string in a source string|`>>> (string-replace "abcdefg" "de" "DE") => "abcDEfg"`| |`(string-regex? where regex)`| Returns true if where contains regex|`>>> (string-regex? "aba123cdefg" "[0-9]+") => 1`| |`(string-pad str len char rpad_lpad)`||| +|`(string-lpad str len char)`||| +|`(string-rpad str len char)`||| +|`(string-split str separator)`||| +`(string-rltrim str len RKRRKR)`| || +`(string-ltrim str)`|Removes " \n\r\t" from the begininfg of str|| +`(string-rtrim str)`|Removes " \n\r\t" from the end of str|| +`(string-trim str)`|Removes " \n\r\t" from the both strart and end of str|| +`(string-case str RKRRKR)`||| +`(string-upcase str)`||| +`(string-downcase str)`||| +`(endl)`||| |`(int value)`|Cast an item to an int|`>>> (int 3.41) => 3`| |`(float value)`|Cast item to a float|`>>> (int 3.41) => 3.14`| |`(string value)`|Cast int or float item to a string|`>>> (string 3.14) => "3.14"`| @@ -83,7 +96,48 @@ |`(parse ..)`||| |`(make-list-of size value)`|Makes list with size elements of values|| |`(make-list size)`|Makes list of nil values with size length|| +|`(memeber lst item)`|Returns 1 when item is inluded in lst otherwise 0|| |`(uniq list)`||| |`(flatten list)`||| -|`(benchmark msg_string code..)`|Benchmarks a block of expressions|Returns value od benchmarked code| +|`(quick-sort-by list cmp)`||| +|`(quick-sort list)`||| +|`(not c)`|Logical NOT of c|| +|`(new n)`|Negates number|| +|`(is-pos? n)`|Returns true if n is positive number|| +|`(is-neg? n)`|Returns true if n is negative number|| +|`(dec n)`|Return n decremented by 1|| +|`(inc n)`|Return n incremented by 1|| +|`(sleep time)`|Pauses execution for time interval of seconds|| +|`(get-env var)`|Return environment variable var|| +|`(second l)`|Returns second element of list|| +|`(third l)`|Returns third element of list|| +|`(fourth l)`|Returns fourth element of list|| +|`(fifth l)`|Returns fifth element of list|| +|`(nth i l)`|Return i-th elemenet of list. First element has index 1|| +|`( make-csv list)`|creates csv string from list of lists|(print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2")))) +|`(sprintf ..)`||| + |`(xx ..)`||| + +``` +(define term-rst-esc "\x1B[0m") +(define term-red-esc '"\x1B[31m") +(define term-green-esc "\x1B[32m") +(define term-yellow-esc "\x1B[33m") +(define term-blue-esc "\x1B[34m") +(define term-magenta-esc "\x1B[35m") +(define term-cyan-esc "\x1B[36m") +(define term-white-esc "\x1B[37m") +(define term-bold-esc "\x1B[1m") +(define term-underline-esc "\x1B[4m") + +(defun term-red (str) (sprintf (+ term-red-esc str term-rst-esc))) +(defun term-green (str) (sprintf (+ term-green-esc str term-rst-esc))) +(defun term-yellow (str) (sprintf (+ term-yellow-esc str term-rst-esc))) +(defun term-blue (str) (sprintf (+ term-blue-esc str term-rst-esc))) +(defun term-magenta (str) (sprintf (+ term-magenta-esc str term-rst-esc))) +(defun term-cyan (str) (sprintf (+ term-cyan-esc str term-rst-esc))) +(defun term-white (str) (sprintf (+ term-white-esc str term-rst-esc))) +(defun term-bold (str) (sprintf (+ term-bold-esc str term-rst-esc))) +(defun term-underline (str) (sprintf (+ term-underline-esc str term-rst-esc))) +``` \ No newline at end of file