From eed18e0f90baaa32781867e3b4cdef1ba9d0d687 Mon Sep 17 00:00:00 2001 From: VaclavT Date: Sat, 6 Mar 2021 19:05:37 +0100 Subject: [PATCH] fixes & updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit added uniq function
task.json
doc updates
 --- .vscode/tasks.json | 23 +++++++++++++++++++++++ Readme.md | 22 ++++++++++++++-------- debug.lsp | 10 +++++----- doc/Doc.md | 3 ++- stdlib/stdlib.lsp | 15 ++++++++++++++- tests/test.lsp | 4 +++- tmp/malformed_program.lsp | 30 +++++------------------------- 7 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..18eb254 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "ml -f debug.lsp", + "type": "shell", + "command": "ml -f debug.lsp", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "ml -f tests/test.lsp", + "type": "shell", + "command": "ml -f tests/test.lsp", + "isDefault": false, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index 2ec0c7d..e6357ea 100644 --- a/Readme.md +++ b/Readme.md @@ -5,24 +5,24 @@ ### TODO - test whether AIG,,,10 csv row is parsed - support for (), nil, t, in lsp code replace 0 by nil in logicals -- print-table +- 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 - rename data.csv and add more tickers -- logical operators - add url of source/inspiration to clib/*.cpp - add stdtest - to test every functionality - rename ivaluize - add benchmark -- add some debug support?? -- add instrumentation (time, nr of evals, debug info, debug environment etc) +- add instrumentation (time, nr of evals, num of atoms, debug info, debug environment etc) - in casting functions (as_string..) better exception description - add better print (syntax high-lighting) -- add command line options -h -v -- readline +- add command line options -h for help, -v for version, -b for no stdlib.lsp on startup +- add readline like functionality (libnoise) +- multiline editting (kilo editor) - execute system command should capture stderr - add builtin sleep - add built in for and, or +- add some debug support - file functions - name it here - string functions @@ -36,12 +36,10 @@ - set env - add hash datatype - conversion functions like parse-integer -- list function nth - in test.lisp some explaining prints - format (printf) - setq - mapcar (funcall, apply) -- if then else, else part is optionw, allow then clause #### Performance - push_back - repeatedly without reserving size @@ -52,6 +50,12 @@ cp build/ml /usr/local/bin/ml cp stdlib/stdlib.lsp /usr/local/var/mlisp/stdlib.lsp ``` +#### 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 +``` +or +cmake ### Example of use ``` @@ -63,6 +67,8 @@ time ./build/ml -c '(include "../example.lisp") (print (fact 1000))' https://hyperpolyglot.org/lisp https://www.tutorialspoint.com/lisp/index.htm https://github.com/adam-mcdaniel/wisp +http://www.ulisp.com/show?1AWG +http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ https://github.com/dropbox/json11 diff --git a/debug.lsp b/debug.lsp index 8862f80..48ceff6 100644 --- a/debug.lsp +++ b/debug.lsp @@ -1,5 +1,5 @@ -(print "Debug starts") - - - -(print "Debug ends") +(print +"ahoj" +; tenhle komentar je problem + ) +(print "sds") \ No newline at end of file diff --git a/doc/Doc.md b/doc/Doc.md index b68934e..33ab2bc 100644 --- a/doc/Doc.md +++ b/doc/Doc.md @@ -40,7 +40,8 @@ |`(first list)`|Returns first element of a list|First element| |`(last list)`|Returns last element of list|Last element| |`(range low high)`|Returns list with elements in range low .. high|`(range 1 5) => (1 2 3 4)`| -|`(member list item)`||| +|`(member list item)`|Returns true (1) when list contains item|| +|`(uniq list)`|Returns list with removed duplicates || |`(make-list len)`|Return list with len nil elements|`(make-list 3) => (nil nil nil)`| |`(make-list-of len value)`||| |`(map ..)`||`(map (lambda (x) (+ x 10)) '(1 2 3 4 5 6)) => (11 12 13 14 15 16)`| diff --git a/stdlib/stdlib.lsp b/stdlib/stdlib.lsp index 6b84c49..8d18806 100644 --- a/stdlib/stdlib.lsp +++ b/stdlib/stdlib.lsp @@ -85,8 +85,21 @@ (defun make-list (size) (make-list-of size nil)) +(defun uniq (lst) + (do + (define rslt '()) + (define i 0) + (define lst_len (len lst)) + (while (< i lst_len) + (define e (index lst i)) + (if (not (member rslt e)) + (define rslt (push rslt e))) + + (define i (inc i))) + + rslt + )) -; quicksort (defun quick-sort-by (l cmp) (if (<= (len l) 1) l diff --git a/tests/test.lsp b/tests/test.lsp index ad93dfc..9463e7f 100644 --- a/tests/test.lsp +++ b/tests/test.lsp @@ -150,6 +150,8 @@ ; (print (filter (lambda (x) (= (first x) "CLX")) csv_list)) (print (filter (lambda (x) (member my_tickers (first x))) csv_list)) - +(define l '(1 2 2 2 3 4 5 4 4 1 2 2 2 3 4 5 4 4 61 2 2 2 3 4 5 4 4 66)) +(print "list:" l) +(print "uniq-ed list:" (uniq l)) (print "Test ends") \ No newline at end of file diff --git a/tmp/malformed_program.lsp b/tmp/malformed_program.lsp index d6ec78b..73015fb 100644 --- a/tmp/malformed_program.lsp +++ b/tmp/malformed_program.lsp @@ -1,25 +1,5 @@ -(print "Debug starts") - -(define csv_list '()) -(for f (ls-dir "tests/divi") - (if (regex-search? f "^divi_2021-02-0[1].*\.csv$") - (do - (define filename (+ "tests/divi/" f)) - ; (print filename) - (define csv_str (read-file filename)) - (define csv_file_list (parse-csv csv_str)) - (define csv_list (+ csv_list csv_file_list)) - ; (for x csv_file_list - ; (print x) - ; (define csv_list (+ csv_list csv_file_list)) - ; ) - ) - )) - -(for x csv_list - (print x)) - -; (if (> 1 10) -; (print "aaa")) - -(print "Debug ends") +(print +"ahoj" +; tenhle komentar je problem +) +(print "sds") \ No newline at end of file