From bd8f0773c6b7c5c231b1d82ad8026eac4edf3bee Mon Sep 17 00:00:00 2001 From: vaclavt Date: Sat, 22 Jan 2022 23:04:45 +0100 Subject: [PATCH] documentation updates --- doc/Doc.md | 75 +++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/doc/Doc.md b/doc/Doc.md index 0fc27b6..6e9a712 100644 --- a/doc/Doc.md +++ b/doc/Doc.md @@ -58,18 +58,20 @@ |`(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| -|`(head list)`|Returns first element of a list|First element|List manipulation| -|`(tail list)`|Return all elements of list except first one|List without first element|List manipulation| -|`(first list)`|Returns first element of a list|First element|List manipulation| -|`(last list)`|Returns last element of list|Last element|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| +|`(last list)`|Returns last element of list|`>>> (last '(1 2 3)) => 2`|List manipulation| |`(range low high)`|Returns list with elements in range low .. high|`(range 1 5) => (1 2 3 4)`|List manipulation| -|`(member list item)`|Returns true when list contains item||List manipulation| -|`(uniq list)`|Returns list with removed duplicates ||List manipulation| +|`(member lst item)`|Returns #t when item is inluded in lst otherwise nil||List manipulation| +|`(uniq list)`|Filter out any duplicates from list|`>>> (uniq '(1 2 2 3 4 5 2 2)) => (1 2 3 4 5)`|List manipulation| +|`(flatten list)`|Flattens a list to single level|`>>> (flatten '(1 (2 2) 3)) => (1 2 2 3)`|List manipulation| +|`(take list count)`|Returns sublist with count element of list|`>>> (take '(1 2 3 4) 3) => (1 2 3)`|List manipulation| |`(make-list len)`|Return list with len nil elements|`(make-list 3) => (nil nil nil)`|List manipulation| |`(make-list-of len value)`|Return list with len value elements||List manipulation| -|`(map ..)`||`(map (lambda (x) (+ x 10)) '(1 2 3 4 5 6)) => (11 12 13 14 15 16)`|List manipulation| -|`(filter lambda list)`||`(filter (lambda (x) (> x 2)) '(1 2 3 4 5)) => (3 4 5)`|List manipulation| -|`(reduce lambda acumulator list)`||`>>> (reduce (lambda (x y) (+ (* x 10) y)) 0 '(1 2 3 4)) => 1234`|List manipulation| +|`(map ..)`|Returns list that is the result of executing lambda on its elements|`(map (lambda (x) (+ x 10)) '(1 2 3 4 5 6)) => (11 12 13 14 15 16)`|List manipulation| +|`(filter lambda list)`|Returns list with elements for which passed lambda returns true|`(filter (lambda (x) (> x 2)) '(1 2 3 4 5)) => (3 4 5)`|List manipulation| +|`(reduce lambda acumulator list)`|Reduces list|`>>> (reduce (lambda (x y) (+ (* x 10) y)) 0 '(1 2 3 4)) => 1234`|List manipulation| |`(exit code)`|Exit the program with an integer code||System| |`(quit code)`|Same as (exit ..)||System| |`(print ..)`|Print several values and return the last one||IO| @@ -95,52 +97,49 @@ |`(date-to-str date format)`|Converts date to formated string. Format is strftime format (https://www.tutorialspoint.com/c_standard_library/c_function_strftime.htm)|`>>> (date-to-str (get-universal-time) "%Y-%m-%d %H:%M:%S") => "2021-03-13 19:53:01"`|Date and time| |`(str-to-date string format)`|Converst string to time of secs since epoch. |`>>> (str-to-date "2021-03-13 19:53:01" "%Y-%m-%d %H:%M:%S") => 1615665181`|Date and time| |`(date-add date amount unit)`|Add number of units to date. A unit is one of 'year', 'month', 'day', 'hour', 'minute' or 'second'|`>>> (date-to-str (date-add (str-to-date "2021-03-13 19:53:01" "%Y-%m-%d %H:%M:%S") 10 "day") "%Y-%m-%d %H:%M:%S") => "2021-03-23 20:53:01"`|Date and time| -|`start-of-day datetime`||`>>> (start-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1620864000`|Date and time| -|`end-of-day datetime`||`>>> (end-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1620950399`|Date and time| -|`start-of-month datetime`||`>>> (start-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1619827200`|Date and time| -|`start-of-next-month datetime`||`>>> (end-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1622505599`|Date and time| -|`end-of-next-month datetime`||`>>> (start-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1622505600`|Date and time| -|`end-of-month datetime`||`>>> (end-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1625097599`|Date and time| -|`start-of-prev-month datetime`||`>>> (start-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1617235200`|Date and time| -|`end-of-prev-month datetime`||`>>> (end-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1619827199`|Date and time| -|`start-of-year datetime`||`>>> (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1609459200`|Date and time| -|`end-of-year datetime`||`>>> (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1640995199`|Date and time| -|`(debug ..)`|||IO| +|`start-of-day datetime`|Returns epoch time of start of a day|`>>> (start-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1620864000`|Date and time| +|`end-of-day datetime`|Returns epoch time of end of day|`>>> (end-of-day (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1620950399`|Date and time| +|`start-of-month datetime`|Returns epoch time of start of month|`>>> (start-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1619827200`|Date and time| +|`start-of-next-month datetime`|Returns epoch time of start of following month|`>>> (start-of-next-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1622505599`|Date and time| +|`end-of-next-month datetime`|Returns epoch time of end of following month|`>>> (end-of-next-month datetime (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1622505600`|Date and time| +|`end-of-month datetime`|Returns epoch time of end of month|`>>> (end-of-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1625097599`|Date and time| +|`start-of-prev-month datetime`|Returns epoch time of start of previous month|`>>> (start-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1617235200`|Date and time| +|`end-of-prev-month datetime`|Returns epoch time of end of previous month|`>>> (end-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1619827199`|Date and time| +|`start-of-year datetime`|Returns epoch time of start of year|`>>> (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1609459200`|Date and time| +|`end-of-year datetime`|Returns epoch time of end of year|`>>> (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1640995199`|Date and time| +|`(debug ..)`|TODO add me|TODO add me|IO| |`(display ..)`|Displays passed parameters|`>>> (display '(1 2 3)) => "(1 2 3)"`|IO| |`(string-replace source substr replacement)`|Replace a substring with a replacement string in a source string|`>>> (string-replace "abcdefg" "de" "DE") => "abcDEfg"`|String manipulation| |`(string-replace-re source substr replacement)`|Replace a substring regex with a replacement string in a source string|`>>> (string-replace-re "there is a subsequence in the string" "\\b(sub)([^ ]*)" "sub-$2") => "there is a sub-sequence in the string"`|String manipulation| -|`(string-regex? where regex)`| Returns true if where contains regex|`>>> (string-regex? "aba123cdefg" "[0-9]+") => 1`|Regex| +|`(string-regex? where regex)`| Returns true if where contains regex, else nil|`>>> (string-regex? "aba123cdefg" "[0-9]+") => #t`|Regex| |`(string-regex-list where regex [mode] [ignorecase])`| Returns list of substring from where captured by regex in mode match or tokens|`>>> (string-regex-list "12" "(.*?)" "match" "ignore") => (("1" "2"))` `>>> (string-regex-list "12" "(.*?)" "token") => (("1") ("2"))`|Regex| -|`(string-pad str len char rpad_lpad)`|||String manipulation| +|`(string-pad str len char rpad_lpad)`|Pad string from start or to end with char to length||String manipulation| |`(string-lpad str len char)`|Pad string from start with char to length len|`>>> (string-lpad "0" 10 "x") => "xxxxxxxxx0"`|String manipulation| |`(string-rpad str len char)`|Pad string from righ with char to length len|`>>> (string-rpad "0" 10 "x") => "0xxxxxxxxx"`|String manipulation| |`(string-split str separator)`|Splits string into list by regexp|`>>> (string-split "split me by space" "\s+") => ("split" "me" "by" "space")`| -|`(string-rltrim str len RKRRKR)`|||Regex| -|`(string-ltrim str)`|Removes " \n\r\t" from the begininfg of str||String manipulation| -|`(string-rtrim str)`|Removes " \n\r\t" from the end of str||String manipulation| -|`(string-trim str)`|Removes " \n\r\t" from the both strart and end of str||String manipulation| -|`(string-case str RKRRKR)`|||String manipulation| +|`(string-rltrim str len RKRRKR)`|Removes " \n\r\t" from the begininfg or end or both ends of str||Regex| +|`(string-ltrim str)`|Removes " \n\r\t" from the begininfg of str||String manipulation| +|`(string-rtrim str)`|Removes " \n\r\t" from the end of str||String manipulation| +|`(string-trim str)`|Removes " \n\r\t" from the both strart and end of str||String manipulation| +|`(string-case str RKRRKR)`|Returns up or down cased string||String manipulation| |`(string-upcase str)`|Returns up cased string|`>>> (string-upcase "abcdefghchijklmn") => "ABCDEFGHCHIJKLMN"`|String manipulation| |`(string-downcase str)`|Returns down cased string |`>>> (string-downcase "ABCDefghchijklmn") => "abcdefghchijklmn"`|String manipulation| |`(string-join lst sep)`|Returns string created as elements of concatenation of lst elements separated by sep|`>>> (string-join ("A" "B" "C" "D") ",") => "A,B,C,D"`|String manipulation| |`(string-len str)`|Returns string length|`>>> (string-len "abcdef") => 6`|String manipulation| -|`(string-substr str pos len`|Returns substring from str starting at pos with len. If pos is negative returns substring from the end of string. First character is on pos 0|`>>> (string-substr "ABCD" -2 2) => "CD"`|String manipulation| -|`(string-find str lookup pos`|Returns position of lookup in str starting on position. First char index is 0. If not found returns nil|`>>> (string-find " long long int;" "long" 2) => 6`|String manipulation| +|`(string-substr str pos len)`|Returns substring from str starting at pos with len. If pos is negative returns substring from the end of string. First character is on pos 0|`>>> (string-substr "ABCD" -2 2) => "CD"`|String manipulation| +|`(string-find str lookup pos)`|Returns position of lookup in str starting on position. First char index is 0. If not found returns nil|`>>> (string-find " long long int;" "long" 2) => 6`|String manipulation| |`(int value)`|Cast an item to an int|`>>> (int 3.41) => 3`|Type casting| |`(float value)`|Cast item to a float|`>>> (int 3.41) => 3.14`|Type casting| |`(string value)`|Cast int or float item to a string|`>>> (string 3.14) => "3.14"`|Type casting| |`(eval )`|Eval returns the value of the second evaluation|`>>> (eval '(+ 1 2)) => 3`|Language| |`(type e)`|Returns data type of e|`>>> (type (+ 1 2)) => "int"`|Type casting| -|`(parse ..)`||`>>> (eval (first (parse "(+ 1 2)"))) => 3`|Language| +|`(parse ..)`|Parses string to be evaluated|`>>> (eval (first (parse "(+ 1 2)"))) => 3`|Language| |`(make-list-of size value)`|Makes list with size elements of values|`>>> (make-list-of 5 0) => (0 0 0 0 0)`|List manipulation| |`(make-list size)`|Makes list of nil values with size length|`>>> (make-list 5) => (nil nil nil nil nil)`|List manipulation| |`(empty-list? lst)`|Return true is lst is list with zero elements|`>>> (empty-list? '()) => 1`|Type casting| -|`(memeber lst item)`|Returns 1 when item is inluded in lst otherwise 0||List manipulation| -|`(uniq list)`|Filter out any duplicates from list|`>>> (uniq '(1 2 2 3 4 5 2 2)) => (1 2 3 4 5)`|List manipulation| -|`(flatten list)`||`>>> (flatten '(1 (2 2) 3)) => (1 2 2 3)`|List manipulation| -|`(quick-sort-by list cmp)`|||Language| -|`(quick-sort list)`|return sorted list|`>>> (quick-sort '(2 4 6 1 7 3 3 9 5)) => (1 2 3 3 4 5 6 7 9)`|Language| -|`(quick-sort-reverse list)`|return reverse sorted list|`>>> (quick-sort-reverse '(2 4 6 1 7 3 3 9 5)) => (9 7 6 5 4 3 3 2 1)`|Language| +|`(quick-sort-by list cmp)`|Returns list sorted by comparsion function||Language| +|`(quick-sort list)`|Return sorted list|`>>> (quick-sort '(2 4 6 1 7 3 3 9 5)) => (1 2 3 3 4 5 6 7 9)`|Language| +|`(quick-sort-reverse list)`|Return reverse sorted list|`>>> (quick-sort-reverse '(2 4 6 1 7 3 3 9 5)) => (9 7 6 5 4 3 3 2 1)`|Language| |`(not c)`|Logical NOT of c|`>>> (not 1) => nil`|Logical| |`(neg n)`|Negates number|`>>> (neg -5) => 5`|Language| |`(is-pos? n)`|Returns true if n is positive number||Language| @@ -155,11 +154,11 @@ |`(fifth list)`|Returns fifth element of list|`>>> (fifth '(1 2 3 4 5 6 7)) => 5`|List manipulation| |`(nth i list)`|Return i-th elemenet of list. First element has index 1|`>>> (nth 7 '(1 2 3 4 5 6 7)) => 7`|List manipulation| |`(make-csv list)`|creates csv string from list of lists|(print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2"))))|List manipulation| -|`(sprintf ..)`||`>>> (sprintf "%s, %d, %.2f" (list "string" 1000 3.14)) => "string, 1000, 3.14"`|String manipulation| +|`(sprintf ..)`|Writes string pointed by format to the standard output|`>>> (sprintf "%s, %d, %.2f" (list "string" 1000 3.14)) => "string, 1000, 3.14"`|String manipulation| |`(thread-create code..)`|Creates new thread, starts evalueating code and returns immediatelly thread id||Threading| |`(thread-under-lock lockname code)`|Acquire lock with lockname and eval code. "ilock" currently is only allowed lockname||Threading| |`(thread-sleep milisecons)`|Sleeps thread for given amount of miliseconds||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-exception exp_desc)`|Throws an exception with exp_desc describing what happened ||Exceptions| -|`(xx ..)`|||| +|`(xx ..)`|Desc|example|section| \ No newline at end of file