Compare commits

..

3 Commits

Author SHA1 Message Date
vaclavt
062edbac3c initial version of docker file 2022-04-25 21:39:31 +02:00
vaclavt
caf6648867 reduce test and doc update 2022-04-25 20:20:48 +02:00
vaclavt
245143bd9e small compiler warnings fixed 2022-04-25 20:20:19 +02:00
6 changed files with 40 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ std::pair<int, std::string> HttpClient::doRequest(const std::string &method, con
// and fetch the rest if not read completely
while (content_len > 0 && content_len > ssl_read_packet.length() - 4 - end_of_headers) {
auto read_bytes = sslRecvPacket();
/* auto read_bytes = */ sslRecvPacket();
}
// get body

View File

@@ -1 +1,4 @@
(system-cmd-fork "ml" "-c" "(print 123) (sleep 1) (print \"aaa\")")
; (system-cmd-fork "ml" "-c" "(print 123) (sleep 1) (print \"aaa\")")
(print (reduce (lambda (acc e) (+ acc (string (+ "<th>" e "</th>")))) "" '("h1" "h2" "h3"))
)

View File

@@ -76,7 +76,7 @@
|`(find-val-in-list lst name)`|Returns tail od sublist which first element is name|`>>> (find-val-in-list '(("a" ("av" "avv")) ("b" "bv") (31 32 33) (41 42 43)) "b") => "bv" >>> `|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|
|`(reduce lambda acumulator list)`|Reduces list|`>>> (reduce (lambda (acc e) (+ (* acc 10) e)) 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 one or several values separated by space and return the last one|`>>> (print "pi" "is" 3.14)\npi is 3.140000 => 3.140000`|IO|

31
docker/Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
# docker build -t ml:latest .
# docker run --rm -it ml ml -v
# docker run --rm -it --entrypoint sh ml
FROM alpine:3.15.4 AS builder
# Install all dependencies required for compiling ml
RUN apk add --verbose build-base musl-dev openssl-dev make git cmake
RUN git clone http://gitea.stocksriddle.one/vaclavt/mlisp.git
# Compile
RUN cd /mlisp \
&& rm -f CMakeCache.txt \
&& cmake -DCMAKE_BUILD_TYPE=Release . \
&& cmake --build ./ --target clean -j 4 -- \
&& cmake --build ./ --target all -j 4 --
# Create image and copy compiled installation into it
FROM alpine:3.15.4
RUN apk add openssl libstdc++
CMD mkdir -p /usr/local/var/mlisp/
COPY --from=builder /mlisp/stdlib/*.lsp /usr/local/var/mlisp/
COPY --from=builder /mlisp/doc/*.md /usr/local/var/mlisp/
CMD mkdir -p /usr/local/bin/
COPY --from=builder /mlisp/ml /usr/local/bin/

View File

@@ -79,7 +79,7 @@ void MlPerfMon::restore_callstack_position(size_t to_position) {
}
void MlPerfMon::clear_callstack() {
bool e = call_stack.empty();
call_stack.empty();
}
void MlPerfMon::print_results() const {

View File

@@ -47,6 +47,8 @@
(ut::define-test "result of (member '(1 2 3) 3)" '(ut::assert-true (member '(1 2 3) 3)))
(ut::define-test "result of (member '(1 2 3) 4)" '(ut::assert-false (member '(1 2 3) 4)))
(ut::define-test "result of (reduce (lambda (acc e) (+ acc (string (+ \"<th>\" e \"</th>\")))) \"\" '(\"h1\" \"h2\" \"h3\"))" '(ut::assert-equal "<th>h1</th><th>h2</th><th>h3</th>" (reduce (lambda (acc e) (+ acc (string (+ "<th>" e "</th>")))) "" '("h1" "h2" "h3"))))
(ut::define-test "result of (take '(1 2 3 4) 3)" '(ut::assert-equal '(1 2 3) (take '(1 2 3 4) 3)))
(ut::define-test "result of (make-list 3)" '(ut::assert-equal '(nil nil nil) (make-list 3)))