-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.lisp
executable file
·106 lines (90 loc) · 2.63 KB
/
package.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(defpackage :N3
(:use :cl)
(:export :*N3-BACKUP-DIRECTORY*
:*ALL-SOM*
:*ALL-AREA*
:CREATE-MLT
:CREATE-AREA
:LOCATE-CLIQUE
:LOCATE-TOURNOI
:LOCATE-CYCLE
:UPDATE-FANAUX
:UPDATE-COVER-VALUE
:LEARN
:SAVE
:COPY
:LOAD-NEURAL-NETWORK
:NEXT-EVENT-PROBABILITY
:*TREE*
:GET-LEAVES
:CAH-FANAUX
:DENDROGRAM
:NET-MENU
:TREE-MENU
:SEQUENCING-MENU
:SEND-UDP
:OSC-LISTEN
:EUCLIDEAN
:EXP-DECAY
:FN-MEX
:GAUSS
:QUADRARE
:RND-MAP
:LAMBDA*
:SCALING
:MAPPING
:DIFFERENTIAL-VECTOR
:*ALL-SEQUENCING*
:CREATE-SEQUENCING
:SET-CORPUS
:SET-PATTERN
:SET-ROUTINE
:SET-RULE
:SET-SUBROUTINE
:SET-SYNC
:ACT-ROUTINE
:KILL-ROUTINE
))
(progn
(ignore-errors (require 'fosc))
(unless (find-package 'fosc) (ignore-errors (require 'osc))))
(in-package :N3)
(setf *random-state* (make-random-state t)
*print-pretty* nil)
;------------------------------------------------------------------
;; src: https://stackoverflow.com/a/60816019/3224092
#+sbcl
(defclass fn-with-code (sb-mop:funcallable-standard-object)
((code :reader source-of :initarg :source)
(function :reader function-of :initarg :function)
(ml :reader save-as :initarg :ml))
(:metaclass sb-mop:funcallable-standard-class))
#+openmcl
(defclass fn-with-code (ccl:funcallable-standard-object)
((code :reader source-of :initarg :source)
(function :reader function-of :initarg :function)
(ml :reader save-as :initarg :ml))
(:metaclass ccl:funcallable-standard-class))
(defmethod initialize-instance :after ((f fn-with-code) &key &allow-other-keys)
#+sbcl
(sb-mop:set-funcallable-instance-function f (function-of f))
#+openmcl
(ccl:set-funcallable-instance-function f (function-of f)))
(defun make-fn-with-code (function source ml)
(make-instance 'fn-with-code :source source :function function :ml ml))
(defmacro lambda* ((&rest args) &body body)
(let ((code `(lambda ,args ,@body))
(ml `(lambda* ,args ,@body)))
`(make-fn-with-code ,code ',code ',ml)))
(defgeneric ml! (o)
(:method ((o fn-with-code)) (save-as o))
(:method ((o t)) (declare (ignore o)) nil))
(defgeneric ml? (o)
(:method ((o fn-with-code)) (declare (ignore o)) t)
(:method ((o t)) (declare (ignore o)) nil))
(defmethod print-object ((o fn-with-code) stream)
(print-unreadable-object (o stream :type nil :identity nil)
(format stream "FUNCTION ~S" (source-of o))))
; > (lambda* (x y) (* x y))
; #<FUNCTION (LAMBDA (X Y) (* X Y))>
;------------------------------------------------------------------