Changeset 1066 for branches/f4grobner
- Timestamp:
- 2015-06-10T09:12:53-07:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r1054 r1066 322 322 (declare (type poly p)) 323 323 (reduce (ring-gcd ring) (mapcar #'term-coeff (rest (poly-termlist p))) :initial-value (poly-lc p))) 324 325 (defun parse-expr (&optional stream) 326 "Parser of infix expressions with integer/rational coefficients 327 The parser will recognize two kinds of polynomial expressions: 328 329 - polynomials in fully expanded forms with coefficients 330 written in front of symbolic expressions; constants can be optionally 331 enclosed in (); for example, the infix form 332 X^2-Y^2+(-4/3)*U^2*W^3-5 333 parses to 334 (+ (- (EXPT X 2) (EXPT Y 2)) (* (- (/ 4 3)) (EXPT U 2) (EXPT W 3)) (- 5)) 335 336 - lists of polynomials; for example 337 [X-Y, X^2+3*Z] 338 parses to 339 (:[ (- X Y) (+ (EXPT X 2) (* 3 Z))) 340 where the first symbol [ marks a list of polynomials. 341 342 -other infix expressions, for example 343 [(X-Y)*(X+Y)/Z,(X+1)^2] 344 parses to: 345 (:[ (/ (* (- X Y) (+ X Y)) Z) (EXPT (+ X 1) 2)) 346 Currently this function is implemented using M. Kantrowitz's INFIX package." 347 (read-from-string 348 (concatenate 'string 349 "#I(" 350 (with-output-to-string (s) 351 (loop 352 (multiple-value-bind (line eof) 353 (read-line stream t) 354 (format s "~A" line) 355 (when eof (return))))) 356 ")"))) 357
Note:
See TracChangeset
for help on using the changeset viewer.