[1] | 1 | #|
|
---|
| 2 | $Id: example.lisp,v 1.2 2009/01/22 04:01:51 marek Exp $
|
---|
| 3 | *--------------------------------------------------------------------------*
|
---|
| 4 | | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@math.arizona.edu) |
|
---|
| 5 | | Department of Mathematics, University of Arizona, Tucson, AZ 85721 |
|
---|
| 6 | | |
|
---|
| 7 | | Everyone is permitted to copy, distribute and modify the code in this |
|
---|
| 8 | | directory, as long as this copyright note is preserved verbatim. |
|
---|
| 9 | *--------------------------------------------------------------------------*
|
---|
| 10 | |#
|
---|
| 11 |
|
---|
| 12 | (defpackage "CGB-LISP"
|
---|
| 13 | (:use "MAKELIST" "ORDER" "MONOM" "COEFFICIENT-RING"
|
---|
| 14 | "TERM" "POLY" "DIVISION" "PARSE" "PRINTER" "POLY-WITH-SUGAR"
|
---|
| 15 | "GROBNER" "COLORED-POLY" "POLY-GCD" "RAT" "RATPOLY"
|
---|
| 16 | "STRING-GROBNER" "DYNAMICS"
|
---|
| 17 | "INFIX" "COMMON-LISP"))
|
---|
| 18 |
|
---|
[8] | 19 | (proclaim '(optimize (speed 0) (debug 3)))
|
---|
[1] | 20 |
|
---|
| 21 | (defun example (symbol &optional (stream t))
|
---|
| 22 | "Run short examples associated with a symbol, which typically is a function name."
|
---|
| 23 | (dolist (e (cdr (assoc symbol *examples*)))
|
---|
| 24 | (run-example e stream))
|
---|
| 25 | (values))
|
---|
| 26 |
|
---|
| 27 | (defun run-example (e stream)
|
---|
| 28 | "Evaluate a single form E and send output to stream STREAM."
|
---|
| 29 | (format stream "~%;;----------------------------------------------------------------")
|
---|
| 30 | (format stream "~%;;")
|
---|
| 31 | (format stream "~%;;~1T~S" e)
|
---|
| 32 | (format stream "~%;;")
|
---|
| 33 | (format stream "~%;;----------------------------------------------------------------~&")
|
---|
| 34 | (dolist (val (multiple-value-list (eval e)))
|
---|
| 35 | (format stream "[ RETURN VALUE ]-->> ~S~&" val))
|
---|
| 36 | (values))
|
---|
| 37 |
|
---|
| 38 | (defun all-examples (&optional (stream t))
|
---|
| 39 | "Run all available examples and send output to STREAM."
|
---|
| 40 | (dolist (a *examples*)
|
---|
| 41 | (dolist (e (cdr a))
|
---|
| 42 | (run-example e stream)))
|
---|
| 43 | (values))
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | (defvar *examples*
|
---|
| 47 | '((string-grobner . ((string-grobner "[x^2+y,x-y]" '(x y))
|
---|
| 48 | (string-grobner "[y-x^2,z-x^3]" '(x y z) :order #'grevlex>)))
|
---|
| 49 | (string-grobner-system . ((string-grobner-system "[u*x+y,x+y]" '(x y) '(u))
|
---|
| 50 | (string-grobner-system "[u*x+y,x+y]" '(x y) '(u) :cover '(("[u-1]" "[]")))))
|
---|
| 51 | (string-read-poly . ((string-read-poly "[x^3+3*x^2+3*x+1]" '(x))))
|
---|
| 52 | (string-elimination-ideal . ((string-elimination-ideal "[x^2+y^2-2,x*y-1]" '(x y) 1)))
|
---|
| 53 | (string-ideal-saturation . ((string-ideal-saturation "[x^2*y,y^3]" "x" '(x y))))
|
---|
| 54 | (string-ideal-polysaturation . ((string-ideal-polysaturation "[x^2*y,y^3]" "[x,y]" '(x y)))))
|
---|
| 55 | "A list of available examples.")
|
---|
| 56 |
|
---|
| 57 |
|
---|