Commit 24d2f751 authored by Juergen Nickelsen's avatar Juergen Nickelsen

doseq (untested); string and regtest 033; 025 does not yet pass

parent 1b919a12
......@@ -151,6 +151,21 @@
(eval-list body))
(eval resultform)))
(defspecial doseq (formargs &rest body)
"(doseq (loopvar seq resultform) . body)"
(let ((var (car formargs))
(seq (eval (cadr formargs)))
resultform)
(let ((list (if (stringp seq)
(split-string "" seq)
seq)))
(when (consp (cddr formargs))
(setq resultform (caddr formargs)))
(while (consp list)
(set var (pop list))
(eval-list body))
(eval resultform))))
(defun sequencep (object)
"return t if OBJECT is a sequence (list or string), nil else"
(or (listp object) (stringp object)))
......@@ -205,6 +220,10 @@
(apply #'/= (cons n (cddr args)))
(apply #'/= (cdr args))))))
(defun string (&rest args)
"make a string from all args and return it"
(apply #'concat (mapcar #'princs args)))
(defun string<= (&rest args)
"return t if string args are in ascending order (non-strict), else nil"
(if (or (null args) (null (cdr args)))
......
......@@ -12,6 +12,10 @@
* Brandom
* read: does not recognize missong close paren on EOF
* start/end args for dolist/doseq?
@ fix regtests; 024
+ better argument checking (number, types) for Builtins (instead
......
(testcmp "string of nothing" '(string) "")
(testcmp "string single list" '(string '(a b c)) "(a b c)")
(testcmp "string symbols" '(string 'abc 'def) "abcdef")
(testcmp "string strings" '(string "a" "b") "ab")
(testcmp "string mixed" '(string "a" t nil 'huhu (cons 'd '(e f)) 112)
"atnilhuhu(d e f)112")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment