Created
October 28, 2013 19:43
-
-
Save Eskatrem/7203269 to your computer and use it in GitHub Desktop.
Attempt to write the derivative as a first class operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defparameter *maths-functions* (list)) | |
(defmacro defun-maths (func-name args core) | |
"appends the code of func-name into maths-functions." | |
`(progn | |
(push (list (quote ,func-name) (quote ,@args) (quote ,core)) *maths-functions*) | |
(defun ,func-name ,args ,core))) | |
(defparameter *derivatives* | |
(list 'cos '(* -1 sin) | |
'sin 'cos | |
'+ '+)) | |
(defun get-derivative (func) | |
(getf *derivatives* func)) | |
(defun derivative (expr variable) | |
(let* ((func (car expr)) | |
(args (cdr expr)) | |
(der (get-derivative func))) | |
())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment