diff options
-rw-r--r-- | tests/012/infix.tl | 10 | ||||
-rw-r--r-- | txr.1 | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/012/infix.tl b/tests/012/infix.tl index c619db18..79767f31 100644 --- a/tests/012/infix.tl +++ b/tests/012/infix.tl @@ -65,3 +65,13 @@ (x ** a[i][j][k] ++) (expt x (pinc [[[a i] j] k])) (x ** -- a[i][j][k]) (expt x (dec [[[a i] j] k])) (x ** -- a[i + y][j ++][-- k]) (expt x (dec [[[a i + y] j ++] -- k]))) + +(ifx + (defun quadratic-roots (a b c) + (let ((d (sqrt b * b - 4 * a * c))) + (list ((- b + d) / 2 * a) + ((- b - d) / 2 * a))))) + +(mtest + (quadratic-roots 1 0 -4) (2.0 -2.0) + (quadratic-roots 1 2 1) (-1.0 -1.0)) @@ -54327,6 +54327,20 @@ continues to apply, infix subexpressions produced by .code parse-infix are recursively detected and expanded. +.TP* Example + +Calculate the roots of a quadratic formula, when real: + +.verb + (ifx + (defun quadratic-roots (a b c) + (let ((d (sqrt b * b - 4 * a * c))) + (list ((- b + d) / 2 * a) + ((- b - d) / 2 * a))))) + + (quadratic-roots 1 0 -4) -> (2.0 -2.0) + (quadratic-roots 1 2 1) -> (-1.0 -1.0) +.brev .SS* Enumerated Constants The enumerated constants module provides ways for defining |