added two string functions, doc updates
This commit is contained in:
47
doc/Doc.md
47
doc/Doc.md
@@ -57,7 +57,7 @@
|
||||
|`(include file)`|Read a file and execute its code||
|
||||
|`(read-file filename)`|Get the contents of a file||
|
||||
|`(write-file filename)`|Write a string to a file||
|
||||
|`(read-url url [headers])`|Reads URL|Returnd list (status_code content)|
|
||||
|`(read-url url [headers])`|Reads URL|Returns list (status_code content)|
|
||||
|`(system-cmd command_str)`|Execute system command||
|
||||
|`(ls-dir ..)`|List a dir|List of directory entries|
|
||||
|`(is-file? ..)`|Returns true if passed filename is a file||
|
||||
@@ -77,7 +77,7 @@
|
||||
|`(string-pad str len char rpad_lpad)`|||
|
||||
|`(string-lpad str len char)`|Pad string from start with char to length len|`>>> (string-lpad "0" 10 "x") => "xxxxxxxxx0"`|
|
||||
|`(string-rpad str len char)`|Pad string from righ with char to length len|`>>> (string-rpad "0" 10 "x") => "0xxxxxxxxx"`|
|
||||
|`(string-split str separator)`|||
|
||||
|`(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)`| ||
|
||||
`(string-ltrim str)`|Removes " \n\r\t" from the begininfg of str||
|
||||
`(string-rtrim str)`|Removes " \n\r\t" from the end of str||
|
||||
@@ -85,24 +85,26 @@
|
||||
`(string-case str RKRRKR)`|||
|
||||
`(string-upcase str)`|Returns up cased string|`>>> (string-upcase "abcdefghchijklmn") => "ABCDEFGHCHIJKLMN"`|
|
||||
`(string-downcase str)`|Returns down cased string |`>>> (string-downcase "ABCDefghchijklmn") => "abcdefghchijklmn"`|
|
||||
`(string-join lst sep)`|Returns string created as elements of concatenation of lst elements separated by sep||
|
||||
`(endl)`|||
|
||||
`(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-len str)`|Returns string length|`>>> (string-len "abcdef") => 6`|
|
||||
`(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|`>>> (string-substr "ABCD" -2 2) => "CD"`|
|
||||
`(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`|
|
||||
|`(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"`|
|
||||
|`(eval <exp>)`|Eval returns the value of the second evaluation|`>>> (eval '(+ 1 2)) => 3`|
|
||||
|`(type e)`|Returns data type of e|`>>> (type (+ 1 2)) => "int"`|
|
||||
|`(parse ..)`|||
|
||||
|`(make-list-of size value)`|Makes list with size elements of values||
|
||||
|`(make-list size)`|Makes list of nil values with size length||
|
||||
|`(empty-list? lst)`|Return true is lst is list with zero elements||
|
||||
|`(parse ..)`||`>>> (eval (first (parse "(+ 1 2)"))) => 3`|
|
||||
|`(make-list-of size value)`|Makes list with size elements of values|`>>> (make-list-of 5 0) => (0 0 0 0 0)`|
|
||||
|`(make-list size)`|Makes list of nil values with size length|`>>> (make-list 5) => (nil nil nil nil nil)`|
|
||||
|`(empty-list? lst)`|Return true is lst is list with zero elements|`>>> (empty-list? '()) => 1`|
|
||||
|`(memeber lst item)`|Returns 1 when item is inluded in lst otherwise 0||
|
||||
|`(uniq list)`|Filter out any duplicates from list|`>>> (uniq '(1 2 2 3 4 5 2 2)) => (1 2 3 4 5)`|
|
||||
|`(flatten list)`||`>>> (flatten '(1 (2 2) 3)) => (1 2 2 3)`|
|
||||
|`(quick-sort-by list cmp)`|||
|
||||
|`(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)`|
|
||||
|`(not c)`|Logical NOT of c||
|
||||
|`(new n)`|Negates number||
|
||||
|`(not c)`|Logical NOT of c|`>>> (not 1) => nil`|
|
||||
|`(neg n)`|Negates number|`>>> (neg -5) => 5`|
|
||||
|`(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|`>>> (dec 5) => 4`|
|
||||
@@ -115,29 +117,6 @@
|
||||
|`(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 ..)`|||
|
||||
|`(sprintf ..)`||`>>> (sprintf "%s, %d, %.2f" (list "string" 1000 3.14)) => "string, 1000, 3.14"`|
|
||||
|
||||
|`(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)))
|
||||
```
|
||||
Reference in New Issue
Block a user