source: CGBLisp/src/example.lisp@ 1

Last change on this file since 1 was 1, checked in by Marek Rychlik, 15 years ago

First import of a version circa 1997.

File size: 2.5 KB
Line 
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
19#+debug(proclaim '(optimize (speed 0) (debug 3)))
20#-debug(proclaim '(optimize (speed 3) (debug 0)))
21
22(defun example (symbol &optional (stream t))
23 "Run short examples associated with a symbol, which typically is a function name."
24 (dolist (e (cdr (assoc symbol *examples*)))
25 (run-example e stream))
26 (values))
27
28(defun run-example (e stream)
29 "Evaluate a single form E and send output to stream STREAM."
30 (format stream "~%;;----------------------------------------------------------------")
31 (format stream "~%;;")
32 (format stream "~%;;~1T~S" e)
33 (format stream "~%;;")
34 (format stream "~%;;----------------------------------------------------------------~&")
35 (dolist (val (multiple-value-list (eval e)))
36 (format stream "[ RETURN VALUE ]-->> ~S~&" val))
37 (values))
38
39(defun all-examples (&optional (stream t))
40 "Run all available examples and send output to STREAM."
41 (dolist (a *examples*)
42 (dolist (e (cdr a))
43 (run-example e stream)))
44 (values))
45
46
47(defvar *examples*
48 '((string-grobner . ((string-grobner "[x^2+y,x-y]" '(x y))
49 (string-grobner "[y-x^2,z-x^3]" '(x y z) :order #'grevlex>)))
50 (string-grobner-system . ((string-grobner-system "[u*x+y,x+y]" '(x y) '(u))
51 (string-grobner-system "[u*x+y,x+y]" '(x y) '(u) :cover '(("[u-1]" "[]")))))
52 (string-read-poly . ((string-read-poly "[x^3+3*x^2+3*x+1]" '(x))))
53 (string-elimination-ideal . ((string-elimination-ideal "[x^2+y^2-2,x*y-1]" '(x y) 1)))
54 (string-ideal-saturation . ((string-ideal-saturation "[x^2*y,y^3]" "x" '(x y))))
55 (string-ideal-polysaturation . ((string-ideal-polysaturation "[x^2*y,y^3]" "[x,y]" '(x y)))))
56 "A list of available examples.")
57
58
Note: See TracBrowser for help on using the repository browser.