;; (print (string-split "split me by space" "\\s+")) ;; (print (string-rtrim "abc ")) ;; (print (string-ltrim " abc")) ;; (print (string-trim " abc ")) ;; (defun string-upcase (str) ;; (string-case str "upper")) ;; (defun string-downcase (str) ;; (string-case str "lower")) ;; (print (string-upcase "abcABCD")) ;; (print (string-downcase "abcABCD")) ;; (print (sprintf "%.2f" (list 1.25))) ;; (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-red-esc '"\x1B[31m") ;; (define term-green-esc "\x1B[32m") ;; (defun term-red (str) (sprintf (+ term-red-esc str term-rst-esc))) ;; (print (+ (term-red (sprintf "%.2f" (list 1.11))) " " ;; (term-green (sprintf "%.2f" (list 1.11))) " " ;; (term-blue (sprintf "%.2f" (list 1.11))) " " ;; (term-yellow (sprintf "%.2f" (list 1.11))) " " ;; )) ;; (benchmark "benchmark makelist 1000 : " (make-list 1000)) ;; (benchmark "benchmark range 1000 : " (range 1 1000)) ;; (define fdx_list (parse-csv (read-file "tests/csv_data.csv"))) ;; (print fdx_list) ;; (print (and (print "xx") (= 1 0) (print "yy"))) ;; (defun aa () (do ;; (print "prvni") ;; (+ 1 xx) ;; (print "druhy") ;; )) ;; (aa) ; (sleep 1.5) ;; does not work aif n is defined. in that case it is copied to lambda_scope ;; (define multiply-by (lambda (n) (lambda (y) (* y n)))) ;; (define doubler (multiply-by 2)) ;; (define tripler (multiply-by 3)) ;; (doubler 4) ;; (tripler 4) ;https://github.com/anthay/Lisp90/blob/master/lisp90.cpp ;http://howtowriteaprogram.blogspot.com/2010/11/lisp-interpreter-in-90-lines-of-c.html ; https://stackoverflow.com/questions/526082/in-scheme-whats-the-point-of-set (define x 3) (defun foo() (do (define x 4) x)) (defun bar() (do (set! x 4) x)) (foo) ; returns 4 x ; still 3 (bar) ; returns 4 x ; is now 4 (defun mini-uuid (uuid_len) (do (define a_list '("_" "-" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")) (reduce (lambda (acc y) (+ acc y)) "" (map (lambda (e) (index a_list (random 0 (- (len a_list) 1)))) (range 0 uuid_len))) )) (benchmark "uuid 1000x :" (define i 0) (while (< i 1000) (do (mini-uuid 5) (define i (+ i 1))))) (defun plus-jedna() (do (set! xx (+ 1 xx)))) (define xx 3) (plus-jedna) (plus-jedna) (define first_tid (thread-create (while 1 (do (thread-under-lock "ilock" (print 1)) (thread-sleep 50))))) (define second_tid (thread-create (while 1 (do (thread-under-lock "ilock" (print 2)) (thread-sleep 75))))) (print "first thread id:" first_tid) (print "second thread id:" second_tid) (threads-join) (print "ok")