lispmxEn 2021-06-16 14:07:17

A simple mathematical example.

We are given a simple polynomial such as:

f(x) = x² + 3x + 4


What is the value of f(x) when x = 3?

We compute this by substituting the value of 3 for x in the expression.

If we do that, we have the result:


f(3) = 3² + 3(3) + 4 = 22


Now, we are using Lisp

define a function like this:


(defun fx (x)

  (+ (expt x 2) (* 3 x) 4))


Finally, we call the function:

(fx 3)

22


You can execute the code in your browser

Here: https://jscl-project.github.io/