Skip to content

Instantly share code, notes, and snippets.

@Eskatrem
Created October 28, 2013 19:43
Show Gist options
  • Save Eskatrem/7203269 to your computer and use it in GitHub Desktop.
Save Eskatrem/7203269 to your computer and use it in GitHub Desktop.
Attempt to write the derivative as a first class operator
(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