defmacro added, doc improvements
This commit is contained in:
@@ -86,6 +86,9 @@
|
||||
(defn doc::appropos (which)
|
||||
(doc::look which))
|
||||
|
||||
(defn doc::lookup (which)
|
||||
(doc::look which))
|
||||
|
||||
;(defn doc::section (which)
|
||||
; (print (term-red "implement me!")))
|
||||
|
||||
|
||||
@@ -60,6 +60,26 @@
|
||||
(defn tenth (l) (index l 9))
|
||||
(defn nth (i l) (index l (- i 1)))
|
||||
|
||||
|
||||
(defn list? (e) (= (type e) "list"))
|
||||
(defn empty-list? (e) (and (list? e) (= (len e) 0)))
|
||||
(defn string? (e) (= (type e) "string"))
|
||||
(defn int? (e) (= (type e) "int"))
|
||||
(defn float? (e) (= (type e) "float"))
|
||||
(defn nil? (e) (= (type e) "nil"))
|
||||
(defn true? (e) (= (type e) "#t"))
|
||||
(defn function? (e) (= (type e) "function"))
|
||||
|
||||
|
||||
(defmacro unless (test v)
|
||||
(list 'if (list 'not test) v))
|
||||
|
||||
(defmacro dotimes (v n body)
|
||||
(list 'for v '(range 0 (eval n))
|
||||
body
|
||||
))
|
||||
|
||||
|
||||
; return 1 when list contains item otherwise nil
|
||||
(defn member (lst itm)
|
||||
(do
|
||||
@@ -92,8 +112,6 @@
|
||||
(defn make-list (size)
|
||||
(make-list-of size nil))
|
||||
|
||||
(defn empty-list? (lst) (and (= (type lst) "list") (= (len lst) 0)))
|
||||
|
||||
(defn uniq (lst)
|
||||
(do
|
||||
(def rslt '())
|
||||
@@ -126,6 +144,12 @@
|
||||
(if (> (len lst) n)
|
||||
(map (lambda (i) (index lst i)) (range 0 n))
|
||||
lst))
|
||||
|
||||
(defn concat-lists (seq1 seq2)
|
||||
(do (def l seq1)
|
||||
(dotimes i (len seq2)
|
||||
(set! l (push l (index seq2 i))))
|
||||
))
|
||||
|
||||
(defn quick-sort-by (l cmp)
|
||||
(if (<= (len l) 1)
|
||||
@@ -253,5 +277,6 @@
|
||||
)
|
||||
))
|
||||
|
||||
; load and init do system
|
||||
|
||||
; load and init doc system
|
||||
(include "/usr/local/var/mlisp/doc.lsp")
|
||||
Reference in New Issue
Block a user