small fixes
This commit is contained in:
parent
3f46ae9c94
commit
11ad7fc3bc
12
Readme.md
12
Readme.md
|
|
@ -1,11 +1,10 @@
|
||||||
|
|
||||||
### BUGS
|
### BUGS
|
||||||
|
- (read-file "nonexisting/file.csv") shows only "could not open file"
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
- test whether AIG,,,10 csv row is parsed
|
|
||||||
- support for (), nil, t, in lsp code replace 0 by nil in logicals
|
- support for (), nil, t, in lsp code replace 0 by nil in logicals
|
||||||
- some performance functionality (at least counting how many times symbol was evaluated)
|
- some performance functionality (at least counting how many times symbol was evaluated)
|
||||||
- download 10 years of data from api.nasdaq.com into test dir
|
|
||||||
- documentation
|
- documentation
|
||||||
- add url of source/inspiration to clib/*.cpp
|
- add url of source/inspiration to clib/*.cpp
|
||||||
- add stdtest - to test every functionality
|
- add stdtest - to test every functionality
|
||||||
|
|
@ -27,6 +26,8 @@
|
||||||
- string functions
|
- string functions
|
||||||
- compare - needed for sorting
|
- compare - needed for sorting
|
||||||
- uppper/lower case
|
- uppper/lower case
|
||||||
|
- trim
|
||||||
|
- replace
|
||||||
- regexp functions
|
- regexp functions
|
||||||
- date support
|
- date support
|
||||||
- decode-universal-time
|
- decode-universal-time
|
||||||
|
|
@ -36,22 +37,23 @@
|
||||||
- add hash datatype
|
- add hash datatype
|
||||||
- conversion functions like parse-integer
|
- conversion functions like parse-integer
|
||||||
- in test.lisp some explaining prints
|
- in test.lisp some explaining prints
|
||||||
- format (printf)
|
- format (sprintf)
|
||||||
- setq
|
- setq
|
||||||
- mapcar (funcall, apply)
|
- mapcar (funcall, apply)
|
||||||
|
|
||||||
#### Performance
|
#### Performance
|
||||||
- push_back - repeatedly without reserving size
|
- push_back - repeatedly without reserving size
|
||||||
|
- mini_sprintf - unnecesary copying between vector and list
|
||||||
|
|
||||||
#### Install
|
#### Install
|
||||||
```
|
```
|
||||||
cp build/ml /usr/local/bin/ml
|
cp build/ml /usr/local/bin/ml
|
||||||
cp stdlib/stdlib.lsp /usr/local/var/mlisp/stdlib.lsp
|
cp stdlib/*.lsp /usr/local/var/mlisp/
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Compile
|
#### Compile
|
||||||
```
|
```
|
||||||
gcc -o ml -I/usr/local/opt/openssl/include -Iclib -L/usr/local/lib -L/usr/local/opt/openssl/lib -lm -lstdc++ -lcrypto -lssl -Wl,-stack_size -Wl,0x1000000 --std=c++17 ml.cpp ml_io.cpp ml_date.cpp ml_string.cpp clib/json11.cpp clib/csvparser.cpp clib/sslclient.cpp
|
gcc -o ml -I/usr/local/opt/openssl/include -Iclib -L/usr/local/lib -L/usr/local/opt/openssl/lib -lm -lstdc++ -lcrypto -lssl -Wl,-stack_size -Wl,0x1000000 --std=c++17 ml.cpp ml_io.cpp ml_date.cpp ml_string.cpp clib/json11.cpp clib/csvparser.cpp clib/sslclient.cpp clib/printf.cpp
|
||||||
```
|
```
|
||||||
or
|
or
|
||||||
cmake
|
cmake
|
||||||
|
|
|
||||||
45
debug.lsp
45
debug.lsp
|
|
@ -1,35 +1,26 @@
|
||||||
|
|
||||||
; (print (sprintf "\033[31mred text"))
|
;; (print (sprintf "%.2f" (list 1.25)))
|
||||||
; (print (sprintf "\x1B[31mred text"))
|
|
||||||
|
;; (print (sprintf "%.2f" '(1.23456)))
|
||||||
|
;; (print (sprintf "%d" '(10000000)))
|
||||||
|
|
||||||
|
(define q 1.23)
|
||||||
|
(print (sprintf "%+.2f%%" (list q)))
|
||||||
|
|
||||||
|
(define q -1.23)
|
||||||
|
(print (sprintf "%+.2f%%" (list q)))
|
||||||
|
|
||||||
(define term-rst-esc "\x1B[0m")
|
(define term-rst-esc "\x1B[0m")
|
||||||
(define term-red-esc '"\x1B[31m")
|
(define term-red-esc '"\x1B[31m")
|
||||||
(define term-green-esc "\x1B[32m")
|
(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-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)))
|
|
||||||
|
|
||||||
(print (term-red "red text"))
|
(print (term-red "red") (sprintf "%.2f" (list 1.11)) "ss")
|
||||||
(print (term-green "green text"))
|
|
||||||
(print (term-yellow "yellow text"))
|
(define q_change_str (sprintf "%+.2f %%" (list q)))
|
||||||
(print (term-blue "blue text"))
|
;; (if (>= q_change 0.0)
|
||||||
(print (term-magenta "magenta text"))
|
;; (define q_change_str (term-green q_change_str))
|
||||||
(print (term-cyan "cyan text"))
|
;; (define q_change_str (term-red q_change_str)))
|
||||||
(print (term-white "white text"))
|
|
||||||
(print (term-bold "bold text"))
|
|
||||||
(print (term-underline "underline text"))
|
|
||||||
(print "normal text")
|
|
||||||
3
ml.cpp
3
ml.cpp
|
|
@ -477,7 +477,7 @@ MlValue MlValue::operator%(const MlValue &other) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the name of the type of this value
|
// Get the name of the type of this value
|
||||||
std::string MlValue::get_type_name() {
|
std::string MlValue::get_type_name() const {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QUOTE:
|
case QUOTE:
|
||||||
return QUOTE_TYPE;
|
return QUOTE_TYPE;
|
||||||
|
|
@ -1524,7 +1524,6 @@ namespace builtin {
|
||||||
MlValue sprintf(std::vector<MlValue> args, MlEnvironment &env) {
|
MlValue sprintf(std::vector<MlValue> args, MlEnvironment &env) {
|
||||||
eval_args(args, env);
|
eval_args(args, env);
|
||||||
|
|
||||||
std::string result;
|
|
||||||
if (args.size() < 1 || args.size() > 2)
|
if (args.size() < 1 || args.size() > 2)
|
||||||
throw MlError(MlValue("sprintf", sprintf), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
throw MlError(MlValue("sprintf", sprintf), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
||||||
|
|
||||||
|
|
|
||||||
2
ml.h
2
ml.h
|
|
@ -182,7 +182,7 @@ public:
|
||||||
MlValue operator%(const MlValue &other) const;
|
MlValue operator%(const MlValue &other) const;
|
||||||
|
|
||||||
// Get the name of the type of this value
|
// Get the name of the type of this value
|
||||||
std::string get_type_name();
|
std::string get_type_name() const;
|
||||||
|
|
||||||
std::string display() const;
|
std::string display() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,9 +158,13 @@
|
||||||
(print "list:" l)
|
(print "list:" l)
|
||||||
(print "flatten-ed list:" (flatten l))
|
(print "flatten-ed list:" (flatten l))
|
||||||
|
|
||||||
|
(print (sprintf "%.2f" (list 1.25)))
|
||||||
|
|
||||||
(print (sprintf "%.2f" '(1.23456)))
|
(print (sprintf "%.2f" '(1.23456)))
|
||||||
(print (sprintf "%d" '(10000000)))
|
(print (sprintf "%d" '(10000000)))
|
||||||
|
|
||||||
|
(define q 1.23)
|
||||||
|
(print (sprintf "%.2f" (list q)))
|
||||||
|
|
||||||
(print (term-red "red text"))
|
(print (term-red "red text"))
|
||||||
(print (term-green "green text"))
|
(print (term-green "green text"))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue