Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lisp Polynomial Function
; Nate from Prof Severs SPL class ;EVALUATE A POLYNOMIAL (defun get-coef(term) (car term) ) (defun get-power(term) (car(cdr term)) ) (defun make-term(x y) (list x y) ) (defun evaluate(poly x) (if (null poly) 0 (let ((term (car poly))) (+ (* (get-coef term) (expt x (get-power term)) ) (evaluate (cdr poly) x) ) ) ) ) ;These values would produce a polynomial of 3*5^3+2*5^2+5+10 (setq polynomial '((3 3)(2 2)(1 1)(10 0))) (setq xVal 5) (print (EVALUATE polynomial xVal))
run
|
edit
|
history
|
help
0
associativity-test
L1.8a
L1.9d - semi
V5
93_Чух_1
fibonacci with cond
LISP Funcs
Lab1
Deleting common elements from the List using CLISP
FPLab1Teteria