File: init.miku

package info (click to toggle)
mikutter 4.1.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,260 kB
  • sloc: ruby: 20,126; sh: 183; makefile: 19
file content (54 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;; this is miku primitive operators.
;; don't change this file.
;; normally, you should make another library files.

(require_runtime_library "enumerator")

(def 'defmacro
     (macro (name alist (rest body))
            `(def ,(list 'quote name) (macro ,alist ,@body))))

;; (defmacro setq (var val)
;;   `(set ,(list 'quote var) ,val))
(defmacro setq ((rest args))
  (set 'result '(set))
  (each_slice args 2 #((pair)
                       (append result (list (list 'quote (car pair)) (nth pair 1)))))
  result)

(defmacro defun (name alist (rest body))
  `(def ,(list 'quote name) #(,alist ,@body)))

(defun to_hash (ary)
  (setq result (new Hash))
  (each ary #((pair) (store result (car pair) (cdr pair))))
  result)

(defmacro and ((rest args))
  (if (empty? args)
      t
    (if (<= 2 (size args))
        `(if ,(car args)
             (and ,@(cdr args)))
        (car args))))

(defmacro or (body (rest other))
  `(if ,body
       true
     ,(if other
          `(or ,@other))))

(defmacro let (bind (rest body))
  (#((mapped)
	 `(#(,(map mapped #((node) (car node)))
		 ,@body) ,@(map mapped #((node) (cdr node)))))
   (map bind #((node)
			   (if (listp node)
				   (cons (car node) (nth node 1))
				   (cons node nil))))))

(defmacro progn ((rest body))
  `(#(() ,@body)))

(defmacro cond (condition (rest follow))
  `(if ,(car condition) (progn ,@(cdr condition)) ,(if (not (empty? follow)) (cons 'cond follow))))