-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.lisp
executable file
·72 lines (53 loc) · 1.94 KB
/
base.lisp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(std:in-package #:std.base)
(defgeneric copy (object)
(:documentation "Returns shallow copy of object")
(:method (primitive)
primitive))
(defgeneric + (arg &rest args)
(:documentation ("Common + operation.")))
(defgeneric - (arg &rest args)
(:documentation ("Common - operation.")))
(defgeneric * (arg &rest args)
(:documentation ("Common * operation.")))
(defgeneric / (arg &rest args)
(:documentation ("Common / operation.")))
(defun = (arg &rest args)
(every (lambda (x) (equals arg x)) args))
(defgeneric equals (x y &rest keys &key recursive &allow-other-keys)
(:documentation ("Common logical equality operation (CDR 8)"))
(:method (x y &key &allow-other-keys)
(eq x y)))
(defgeneric compare (x y &rest keys &key recursive &allow-other-keys)
(:documentation ("Common logical comparison operation (CDR 8)
Returns member of '(< > = /=)"))
(:method (x y &key)
(if (equals x y) '= '/=)))
(defun < (arg &rest args)
(and (eq (compare arg (car args)) '<)
(apply #'< args)))
(defun <= (arg &rest args)
(and (member (compare arg (car args)) '(< =))
(apply #'<= args)))
(defun >= (arg &rest args)
(and (member (compare arg (car args)) '(> =))
(apply #'>= args)))
(defun > (arg &rest args)
(and (eq (compare arg (car args)) '>)
(apply #'> args)))
(defun /= (arg &rest args)
(and (every (lambda (x) (not (= arg x))) args)
(/= args)))
;; (defmacro @ (object message &rest more-messages)
;; "Enables message pipelines
;; (@ l (:map (lambda (x) (process x)))) == (mapcar ...)
;; (@ l (:map func) (:reduce #'+)) == (reduce (mapcar ..))"
;; (let ((res
;; (if (listp message)
;; `(message:send ,object . ,message)
;; `(message:send ,object ,message))))
;; (if more-messages
;; `(@ ,res . ,more-messages)
;; res)))
(defmacro eval-always (&body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
. ,body))