1 ;;; calc-lang.el --- calc language functions
3 ;; Copyright (C) 1990-1993, 2001-2016 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This file is autoloaded from calc-ext.el.
32 ;; Declare functions which are defined elsewhere.
33 (declare-function math-compose-vector
"calccomp" (a sep prec
))
34 (declare-function math-compose-var
"calccomp" (a))
35 (declare-function math-tex-expr-is-flat
"calccomp" (a))
36 (declare-function math-read-factor
"calc-aent" ())
37 (declare-function math-read-expr-level
"calc-aent" (exp-prec &optional exp-term
))
39 ;; Declare variables which are defined elsewhere.
40 (defvar calc-lang-slash-idiv
)
41 (defvar calc-lang-allow-underscores
)
42 (defvar calc-lang-allow-percentsigns
)
43 (defvar math-comp-left-bracket
)
44 (defvar math-comp-right-bracket
)
45 (defvar math-comp-comma
)
46 (defvar math-comp-vector-prec
)
48 ;;; Alternate entry/display languages.
50 (defun calc-set-language (lang &optional option no-refresh
)
51 (setq math-expr-opers
(or (get lang
'math-oper-table
) (math-standard-ops))
52 math-expr-function-mapping
(get lang
'math-function-table
)
53 math-expr-variable-mapping
(get lang
'math-variable-table
)
54 calc-language-input-filter
(get lang
'math-input-filter
)
55 calc-language-output-filter
(get lang
'math-output-filter
)
56 calc-vector-brackets
(or (get lang
'math-vector-brackets
) "[]")
57 calc-complex-format
(get lang
'math-complex-format
)
58 calc-radix-formatter
(get lang
'math-radix-formatter
)
59 calc-function-open
(or (get lang
'math-function-open
) "(")
60 calc-function-close
(or (get lang
'math-function-close
) ")"))
62 (setq calc-language lang
63 calc-language-option option
)
64 (calc-change-mode '(calc-language calc-language-option
)
65 (list lang option
) t
)))
67 (defun calc-normal-language ()
70 (calc-set-language nil
)
71 (message "Normal language mode")))
73 (defun calc-flat-language ()
76 (calc-set-language 'flat
)
77 (message "Flat language mode (all stack entries shown on one line)")))
79 (defun calc-big-language ()
82 (calc-set-language 'big
)
83 (message "\"Big\" language mode")))
85 (defun calc-unformatted-language ()
88 (calc-set-language 'unform
)
89 (message "Unformatted language mode")))
92 (defun calc-c-language ()
95 (calc-set-language 'c
)
96 (message "C language mode")))
98 (put 'c
'math-oper-table
99 '( ( "u!" calcFunc-lnot -
1 1000 )
100 ( "~" calcFunc-not -
1 1000 )
101 ( "u+" ident -
1 197 )
108 ( "<<" calcFunc-lsh
170 171 )
109 ( ">>" calcFunc-rsh
170 171 )
110 ( "<" calcFunc-lt
160 161 )
111 ( ">" calcFunc-gt
160 161 )
112 ( "<=" calcFunc-leq
160 161 )
113 ( ">=" calcFunc-geq
160 161 )
114 ( "==" calcFunc-eq
150 151 )
115 ( "!=" calcFunc-neq
150 151 )
116 ( "&" calcFunc-and
140 141 )
117 ( "^" calcFunc-xor
131 130 )
118 ( "|" calcFunc-or
120 121 )
119 ( "&&" calcFunc-land
110 111 )
120 ( "||" calcFunc-lor
100 101 )
121 ( "?" (math-read-if) 91 90 )
122 ( "!!!" calcFunc-pnot -
1 88 )
123 ( "&&&" calcFunc-pand
85 86 )
124 ( "|||" calcFunc-por
75 76 )
125 ( "=" calcFunc-assign
51 50 )
126 ( ":=" calcFunc-assign
51 50 )
127 ( "::" calcFunc-condition
45 46 ))) ; should support full assignments
129 (put 'c
'math-function-table
130 '( ( acos . calcFunc-arccos
)
131 ( acosh . calcFunc-arccosh
)
132 ( asin . calcFunc-arcsin
)
133 ( asinh . calcFunc-arcsinh
)
134 ( atan . calcFunc-arctan
)
135 ( atan2 . calcFunc-arctan2
)
136 ( atanh . calcFunc-arctanh
)
137 ( fma .
(math-C-parse-fma))
138 ( fmax . calcFunc-max
)
139 ( j0 .
(math-C-parse-bess))
140 ( jn . calcFunc-besJ
)
141 ( j1 .
(math-C-parse-bess))
142 ( yn . calcFunc-besY
)
143 ( y0 .
(math-C-parse-bess))
144 ( y1 .
(math-C-parse-bess))
145 ( tgamma . calcFunc-gamma
)))
147 (defun math-C-parse-bess (f val
)
148 "Parse C's j0, j1, y0, y1 functions."
149 (let ((args (math-read-expr-list)))
152 (cond ((eq val
'j0
) '(calcFunc-besJ 0))
153 ((eq val
'j1
) '(calcFunc-besJ 1))
154 ((eq val
'y0
) '(calcFunc-besY 0))
155 ((eq val
'y1
) '(calcFunc-besY 1)))
158 (defun math-C-parse-fma (f val
)
159 "Parse C's fma function fma(x,y,z) => (x * y + z)."
160 (let ((args (math-read-expr-list)))
169 (put 'c
'math-variable-table
173 (put 'c
'math-vector-brackets
"{}")
175 (put 'c
'math-radix-formatter
176 (function (lambda (r s
)
177 (if (= r
16) (format "0x%s" s
)
178 (if (= r
8) (format "0%s" s
)
179 (format "%d#%s" r s
))))))
181 (put 'c
'math-compose-subscr
184 (let ((args (cdr (cdr a
))))
186 (math-compose-expr (nth 1 a
) 1000)
188 (math-compose-vector args
", " 0)
191 (add-to-list 'calc-lang-slash-idiv
'c
)
192 (add-to-list 'calc-lang-allow-underscores
'c
)
193 (add-to-list 'calc-lang-c-type-hex
'c
)
194 (add-to-list 'calc-lang-brackets-are-subscripts
'c
)
196 (defun calc-pascal-language (n)
199 (and n
(setq n
(prefix-numeric-value n
)))
200 (calc-set-language 'pascal n
)
201 (message (if (and n
(/= n
0))
203 "Pascal language mode (all uppercase)"
204 "Pascal language mode (all lowercase)")
205 "Pascal language mode"))))
207 (put 'pascal
'math-oper-table
208 '( ( "not" calcFunc-lnot -
1 1000 )
211 ( "and" calcFunc-and
190 191 )
212 ( "div" calcFunc-idiv
190 191 )
214 ( "u+" ident -
1 185 )
218 ( "or" calcFunc-or
180 181 )
219 ( "xor" calcFunc-xor
180 181 )
220 ( "shl" calcFunc-lsh
180 181 )
221 ( "shr" calcFunc-rsh
180 181 )
222 ( "in" calcFunc-in
160 161 )
223 ( "<" calcFunc-lt
160 161 )
224 ( ">" calcFunc-gt
160 161 )
225 ( "<=" calcFunc-leq
160 161 )
226 ( ">=" calcFunc-geq
160 161 )
227 ( "=" calcFunc-eq
160 161 )
228 ( "<>" calcFunc-neq
160 161 )
229 ( "!!!" calcFunc-pnot -
1 85 )
230 ( "&&&" calcFunc-pand
80 81 )
231 ( "|||" calcFunc-por
75 76 )
232 ( ":=" calcFunc-assign
51 50 )
233 ( "::" calcFunc-condition
45 46 )))
235 (put 'pascal
'math-input-filter
'calc-input-case-filter
)
236 (put 'pascal
'math-output-filter
'calc-output-case-filter
)
238 (put 'pascal
'math-radix-formatter
239 (function (lambda (r s
)
240 (if (= r
16) (format "$%s" s
)
241 (format "%d#%s" r s
)))))
243 (put 'pascal
'math-lang-read-symbol
246 "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Zα-ωΑ-Ω]\\)"
247 math-exp-str math-exp-pos
)
249 (setq math-exp-token
'number
250 math-expr-data
(math-match-substring math-exp-str
1)
251 math-exp-pos
(match-end 1)))))
253 (put 'pascal
'math-compose-subscr
256 (let ((args (cdr (cdr a
))))
257 (while (eq (car-safe (nth 1 a
)) 'calcFunc-subscr
)
258 (setq args
(append (cdr (cdr (nth 1 a
))) args
)
261 (math-compose-expr (nth 1 a
) 1000)
263 (math-compose-vector args
", " 0)
266 (add-to-list 'calc-lang-allow-underscores
'pascal
)
267 (add-to-list 'calc-lang-brackets-are-subscripts
'pascal
)
269 (defun calc-input-case-filter (str)
270 (cond ((or (null calc-language-option
) (= calc-language-option
0))
275 (defun calc-output-case-filter (str)
276 (cond ((or (null calc-language-option
) (= calc-language-option
0))
278 ((> calc-language-option
0)
284 (defun calc-fortran-language (n)
287 (and n
(setq n
(prefix-numeric-value n
)))
288 (calc-set-language 'fortran n
)
289 (message (if (and n
(/= n
0))
291 "FORTRAN language mode (all uppercase)"
292 "FORTRAN language mode (all lowercase)")
293 "FORTRAN language mode"))))
295 (put 'fortran
'math-oper-table
296 '( ( "u/" (math-parse-fortran-vector) -
1 1 )
297 ( "/" (math-parse-fortran-vector-end) 1 -
1 )
299 ( "u+" ident -
1 191 )
305 ( ".LT." calcFunc-lt
160 161 )
306 ( ".GT." calcFunc-gt
160 161 )
307 ( ".LE." calcFunc-leq
160 161 )
308 ( ".GE." calcFunc-geq
160 161 )
309 ( ".EQ." calcFunc-eq
160 161 )
310 ( ".NE." calcFunc-neq
160 161 )
311 ( ".NOT." calcFunc-lnot -
1 121 )
312 ( ".AND." calcFunc-land
110 111 )
313 ( ".OR." calcFunc-lor
100 101 )
314 ( "!!!" calcFunc-pnot -
1 85 )
315 ( "&&&" calcFunc-pand
80 81 )
316 ( "|||" calcFunc-por
75 76 )
317 ( "=" calcFunc-assign
51 50 )
318 ( ":=" calcFunc-assign
51 50 )
319 ( "::" calcFunc-condition
45 46 )))
321 (put 'fortran
'math-vector-brackets
"//")
323 (put 'fortran
'math-function-table
324 '( ( acos . calcFunc-arccos
)
325 ( acosh . calcFunc-arccosh
)
326 ( aimag . calcFunc-im
)
327 ( aint . calcFunc-ftrunc
)
328 ( asin . calcFunc-arcsin
)
329 ( asinh . calcFunc-arcsinh
)
330 ( atan . calcFunc-arctan
)
331 ( atan2 . calcFunc-arctan2
)
332 ( atanh . calcFunc-arctanh
)
333 ( conjg . calcFunc-conj
)
334 ( log . calcFunc-ln
)
335 ( nint . calcFunc-round
)
336 ( real . calcFunc-re
)))
338 (put 'fortran
'math-input-filter
'calc-input-case-filter
)
340 (put 'fortran
'math-output-filter
'calc-output-case-filter
)
342 (put 'fortran
'math-lang-read-symbol
344 (eq (string-match "\\.[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω]?\\."
345 math-exp-str math-exp-pos
) math-exp-pos
)
346 (setq math-exp-token
'punc
347 math-expr-data
(upcase (math-match-substring math-exp-str
0))
348 math-exp-pos
(match-end 0)))))
350 (put 'fortran
'math-compose-subscr
353 (let ((args (cdr (cdr a
))))
354 (while (eq (car-safe (nth 1 a
)) 'calcFunc-subscr
)
355 (setq args
(append (cdr (cdr (nth 1 a
))) args
)
358 (math-compose-expr (nth 1 a
) 1000)
360 (math-compose-vector args
", " 0)
363 (add-to-list 'calc-lang-slash-idiv
'fortran
)
364 (add-to-list 'calc-lang-allow-underscores
'fortran
)
365 (add-to-list 'calc-lang-parens-are-subscripts
'fortran
)
367 ;; The next few variables are local to math-read-exprs in calc-aent.el
368 ;; and math-read-expr in calc-ext.el, but are set in functions they call.
370 (defvar math-exp-token
)
371 (defvar math-expr-data
)
372 (defvar math-exp-old-pos
)
374 (defvar math-parsing-fortran-vector nil
)
375 (defun math-parse-fortran-vector (op)
376 (let ((math-parsing-fortran-vector '(end .
"\000")))
378 (math-read-brackets t
"]")
379 (setq math-exp-token
(car math-parsing-fortran-vector
)
380 math-expr-data
(cdr math-parsing-fortran-vector
)))))
382 (defun math-parse-fortran-vector-end (x op
)
383 (if math-parsing-fortran-vector
385 (setq math-parsing-fortran-vector
(cons math-exp-token math-expr-data
)
387 math-expr-data
"\000")
389 (throw 'syntax
"Unmatched closing `/'")))
391 (defun math-parse-fortran-subscr (sym args
)
392 (setq sym
(math-build-var-name sym
))
394 (setq sym
(list 'calcFunc-subscr sym
(car args
))
399 (defun calc-tex-language (n)
402 (and n
(setq n
(prefix-numeric-value n
)))
403 (calc-set-language 'tex n
)
405 (message "TeX language mode"))
407 (message "TeX language mode with multiline matrices"))
409 (message "TeX language mode with \\hbox{func}(\\hbox{var})"))
412 "TeX language mode with \\hbox{func}(\\hbox{var}) and multiline matrices"))
414 (message "TeX language mode with \\func(\\hbox{var})"))
417 "TeX language mode with \\func(\\hbox{var}) and multiline matrices")))))
419 (defun calc-latex-language (n)
422 (and n
(setq n
(prefix-numeric-value n
)))
423 (calc-set-language 'latex n
)
425 (message "LaTeX language mode"))
427 (message "LaTeX language mode with multiline matrices"))
429 (message "LaTeX language mode with \\text{func}(\\text{var})"))
432 "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices"))
434 (message "LaTeX language mode with \\func(\\text{var})"))
437 "LaTeX language mode with \\func(\\text{var}) and multiline matrices")))))
439 (put 'tex
'math-lang-name
"TeX")
440 (put 'latex
'math-lang-name
"LaTeX")
442 (put 'tex
'math-oper-table
443 '( ( "\\hat" calcFunc-hat -
1 950 )
444 ( "\\check" calcFunc-check -
1 950 )
445 ( "\\tilde" calcFunc-tilde -
1 950 )
446 ( "\\acute" calcFunc-acute -
1 950 )
447 ( "\\grave" calcFunc-grave -
1 950 )
448 ( "\\dot" calcFunc-dot -
1 950 )
449 ( "\\ddot" calcFunc-dotdot -
1 950 )
450 ( "\\breve" calcFunc-breve -
1 950 )
451 ( "\\bar" calcFunc-bar -
1 950 )
452 ( "\\vec" calcFunc-Vec -
1 950 )
453 ( "\\underline" calcFunc-under -
1 950 )
454 ( "u|" calcFunc-abs -
1 0 )
456 ( "\\lfloor" calcFunc-floor -
1 0 )
457 ( "\\rfloor" closing
0 -
1 )
458 ( "\\lceil" calcFunc-ceil -
1 0 )
459 ( "\\rceil" closing
0 -
1 )
460 ( "\\pm" sdev
300 300 )
461 ( "!" calcFunc-fact
210 -
1 )
463 ( "_" calcFunc-subscr
201 200 )
464 ( "u+" ident -
1 197 )
466 ( "\\times" * 191 190 )
471 ( "\\over" / 170 171 )
473 ( "\\choose" calcFunc-choose
170 171 )
474 ( "\\mod" %
170 171 )
475 ( "<" calcFunc-lt
160 161 )
476 ( ">" calcFunc-gt
160 161 )
477 ( "\\leq" calcFunc-leq
160 161 )
478 ( "\\geq" calcFunc-geq
160 161 )
479 ( "=" calcFunc-eq
160 161 )
480 ( "\\neq" calcFunc-neq
160 161 )
481 ( "\\ne" calcFunc-neq
160 161 )
482 ( "\\lnot" calcFunc-lnot -
1 121 )
483 ( "\\land" calcFunc-land
110 111 )
484 ( "\\lor" calcFunc-lor
100 101 )
485 ( "?" (math-read-if) 91 90 )
486 ( "!!!" calcFunc-pnot -
1 85 )
487 ( "&&&" calcFunc-pand
80 81 )
488 ( "|||" calcFunc-por
75 76 )
489 ( "\\gets" calcFunc-assign
51 50 )
490 ( ":=" calcFunc-assign
51 50 )
491 ( "::" calcFunc-condition
45 46 )
492 ( "\\to" calcFunc-evalto
40 41 )
493 ( "\\to" calcFunc-evalto
40 -
1 )
494 ( "=>" calcFunc-evalto
40 41 )
495 ( "=>" calcFunc-evalto
40 -
1 )))
497 (put 'tex
'math-function-table
498 '( ( \\arccos . calcFunc-arccos
)
499 ( \\arcsin . calcFunc-arcsin
)
500 ( \\arctan . calcFunc-arctan
)
501 ( \\arg . calcFunc-arg
)
502 ( \\cos . calcFunc-cos
)
503 ( \\cosh . calcFunc-cosh
)
504 ( \\cot . calcFunc-cot
)
505 ( \\coth . calcFunc-coth
)
506 ( \\csc . calcFunc-csc
)
507 ( \\det . calcFunc-det
)
508 ( \\exp . calcFunc-exp
)
509 ( \\gcd . calcFunc-gcd
)
510 ( \\ln . calcFunc-ln
)
511 ( \\log . calcFunc-log10
)
512 ( \\max . calcFunc-max
)
513 ( \\min . calcFunc-min
)
514 ( \\sec . calcFunc-sec
)
515 ( \\sin . calcFunc-sin
)
516 ( \\sinh . calcFunc-sinh
)
517 ( \\sqrt . calcFunc-sqrt
)
518 ( \\tan . calcFunc-tan
)
519 ( \\tanh . calcFunc-tanh
)
520 ( \\phi . calcFunc-totient
)
521 ( \\mu . calcFunc-moebius
)))
523 (put 'tex
'math-special-function-table
524 '((calcFunc-sum .
(math-compose-tex-sum "\\sum"))
525 (calcFunc-prod .
(math-compose-tex-sum "\\prod"))
526 (calcFunc-sqrt . math-compose-tex-sqrt
)
527 (intv . math-compose-tex-intv
)))
529 (put 'tex
'math-variable-table
532 ( \\alpha . var-alpha
)
533 ( \\beta . var-beta
)
534 ( \\gamma . var-gamma
)
535 ( \\Gamma . var-Gamma
)
536 ( \\delta . var-delta
)
537 ( \\Delta . var-Delta
)
538 ( \\epsilon . var-epsilon
)
539 ( \\varepsilon . var-varepsilon
)
540 ( \\zeta . var-zeta
)
542 ( \\theta . var-theta
)
543 ( \\vartheta . var-vartheta
)
544 ( \\Theta . var-Theta
)
545 ( \\iota . var-iota
)
546 ( \\kappa . var-kappa
)
547 ( \\lambda . var-lambda
)
548 ( \\Lambda . var-Lambda
)
554 ( \\varpi . var-varpi
)
557 ( \\varrho . var-varrho
)
558 ( \\sigma . var-sigma
)
559 ( \\sigma . var-varsigma
)
560 ( \\Sigma . var-Sigma
)
562 ( \\upsilon . var-upsilon
)
563 ( \\Upsilon . var-Upsilon
)
565 ( \\varphi . var-varphi
)
570 ( \\omega . var-omega
)
571 ( \\Omega . var-Omega
)
584 ( \\infty . var-inf
)
585 ( \\infty . var-uinf
)
586 ( \\sum .
(math-parse-tex-sum calcFunc-sum
) )
587 ( \\prod .
(math-parse-tex-sum calcFunc-prod
) )))
589 (put 'tex
'math-punc-table
594 (put 'tex
'math-complex-format
'i
)
596 (put 'tex
'math-input-filter
'math-tex-input-filter
)
598 (put 'tex
'math-matrix-formatter
601 (if (and (integerp calc-language-option
)
602 (or (= calc-language-option
0)
603 (> calc-language-option
1)
604 (< calc-language-option -
1)))
605 (append '(vleft 0 "\\matrix{")
606 (math-compose-tex-matrix (cdr a
))
608 (append '(horiz "\\matrix{ ")
609 (math-compose-tex-matrix (cdr a
))
612 (put 'tex
'math-var-formatter
'math-compose-tex-var
)
614 (put 'tex
'math-func-formatter
'math-compose-tex-func
)
616 (put 'tex
'math-dots
"\\ldots")
618 (put 'tex
'math-big-parens
'("\\left( " .
" \\right)"))
620 (put 'tex
'math-evalto
'("\\evalto " .
" \\to "))
622 (defconst math-tex-ignore-words
623 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right")
624 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ")
625 ("\\quad") ("\\qquad") ("\\hfil") ("\\hfill")
626 ("\\displaystyle") ("\\textstyle") ("\\dsize") ("\\tsize")
627 ("\\scriptstyle") ("\\scriptscriptstyle") ("\\ssize") ("\\sssize")
628 ("\\rm") ("\\bf") ("\\it") ("\\sl")
629 ("\\roman") ("\\bold") ("\\italic") ("\\slanted")
630 ("\\cal") ("\\mit") ("\\Cal") ("\\Bbb") ("\\frak") ("\\goth")
632 ("\\matrix" mat
) ("\\bmatrix" mat
) ("\\pmatrix" mat
)
634 ("\\cr" punc
";") ("\\\\" punc
";") ("\\*" punc
"*")
635 ("\\{" punc
"[") ("\\}" punc
"]")))
637 (defconst math-latex-ignore-words
638 (append math-tex-ignore-words
639 '(("\\begin" begenv
))))
641 (put 'tex
'math-lang-read-symbol
643 (< math-exp-pos
(1- (length math-exp-str
)))
645 (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
646 math-exp-str math-exp-pos
)
647 (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)"
648 math-exp-str math-exp-pos
))
649 (setq math-exp-token
'symbol
650 math-exp-pos
(match-end 0)
651 math-expr-data
(math-restore-dashes
652 (math-match-substring math-exp-str
1)))
653 (let ((code (assoc math-expr-data math-latex-ignore-words
)))
657 ((eq (nth 1 code
) 'punc
)
658 (setq math-exp-token
'punc
659 math-expr-data
(nth 2 code
)))
660 ((and (eq (nth 1 code
) 'mat
)
661 (string-match " *{" math-exp-str math-exp-pos
))
662 (setq math-exp-pos
(match-end 0)
665 (let ((right (string-match "}" math-exp-str math-exp-pos
)))
667 (setq math-exp-str
(copy-sequence math-exp-str
))
668 (aset math-exp-str right ?\
]))))))))))
670 (defun math-compose-tex-matrix (a &optional ltx
)
672 (cons (append (math-compose-vector (cdr (car a
)) " & " 0)
673 (if ltx
'(" \\\\ ") '(" \\cr ")))
674 (math-compose-tex-matrix (cdr a
) ltx
))
675 (list (math-compose-vector (cdr (car a
)) " & " 0))))
677 (defun math-compose-tex-sum (a fn
)
680 (list 'horiz
(nth 1 fn
)
681 "_{" (math-compose-expr (nth 2 a
) 0)
682 "=" (math-compose-expr (nth 3 a
) 0)
683 "}^{" (math-compose-expr (nth 4 a
) 0)
684 "}{" (math-compose-expr (nth 1 a
) 0) "}"))
686 (list 'horiz
(nth 1 fn
)
687 "_{" (math-compose-expr (nth 2 a
) 0)
688 "=" (math-compose-expr (nth 3 a
) 0)
689 "}{" (math-compose-expr (nth 1 a
) 0) "}"))
691 (list 'horiz
(nth 1 fn
)
692 "_{" (math-compose-expr (nth 2 a
) 0)
693 "}{" (math-compose-expr (nth 1 a
) 0) "}"))))
695 (defun math-parse-tex-sum (f val
)
697 (or (equal math-expr-data
"_") (throw 'syntax
"Expected `_'"))
699 (setq save math-exp-old-pos
)
700 (setq low
(math-read-factor))
701 (or (eq (car-safe low
) 'calcFunc-eq
)
703 (setq math-exp-old-pos
(1+ save
))
704 (throw 'syntax
"Expected equation")))
705 (or (equal math-expr-data
"^") (throw 'syntax
"Expected `^'"))
707 (setq high
(math-read-factor))
708 (list (nth 2 f
) (math-read-factor) (nth 1 low
) (nth 2 low
) high
)))
710 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789.
711 (while (string-match "[0-9]\\\\,[0-9]" str
)
712 (setq str
(concat (substring str
0 (1+ (match-beginning 0)))
713 (substring str
(1- (match-end 0))))))
716 (defun math-compose-tex-sqrt (a)
719 (math-compose-expr (nth 1 a
) 0)
722 (defun math-compose-tex-intv (a)
724 (if (memq (nth 1 a
) '(0 1)) "(" "[")
725 (math-compose-expr (nth 2 a
) 0)
727 (math-compose-expr (nth 3 a
) 0)
728 (if (memq (nth 1 a
) '(0 2)) ")" "]")))
730 (defun math-compose-tex-var (a prec
)
731 (if (and calc-language-option
732 (not (= calc-language-option
0))
733 (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'"
734 (symbol-name (nth 1 a
))))
735 (if (eq calc-language
'latex
)
736 (format "\\text{%s}" (symbol-name (nth 1 a
)))
737 (format "\\hbox{%s}" (symbol-name (nth 1 a
))))
738 (math-compose-var a
)))
740 (defun math-compose-tex-func (func a
)
742 (if (and calc-language-option
743 (not (= calc-language-option
0))
744 (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'" func
))
745 (if (< (prefix-numeric-value calc-language-option
) 0)
746 (setq func
(format "\\%s" func
))
747 (setq func
(if (eq calc-language
'latex
)
748 (format "\\text{%s}" func
)
749 (format "\\hbox{%s}" func
)))))
750 (cond ((or (> (length a
) 2)
751 (not (math-tex-expr-is-flat (nth 1 a
))))
752 (setq left
"\\left( "
754 ((and (eq (aref func
0) ?
\\)
756 (string-match "\\hbox{" func
)
757 (string-match "\\text{" func
)))
759 (or (Math-realp (nth 1 a
))
760 (memq (car (nth 1 a
)) '(var *))))
761 (setq left
"{" right
"}"))
762 (t (setq left calc-function-open
763 right calc-function-close
)))
766 (math-compose-vector (cdr a
) ", " 0)
769 (put 'latex
'math-oper-table
770 (append (get 'tex
'math-oper-table
)
771 '(( "\\Hat" calcFunc-Hat -
1 950 )
772 ( "\\Check" calcFunc-Check -
1 950 )
773 ( "\\Tilde" calcFunc-Tilde -
1 950 )
774 ( "\\Acute" calcFunc-Acute -
1 950 )
775 ( "\\Grave" calcFunc-Grave -
1 950 )
776 ( "\\Dot" calcFunc-Dot -
1 950 )
777 ( "\\Ddot" calcFunc-Dotdot -
1 950 )
778 ( "\\Breve" calcFunc-Breve -
1 950 )
779 ( "\\Bar" calcFunc-Bar -
1 950 )
780 ( "\\Vec" calcFunc-VEC -
1 950 )
781 ( "\\dddot" calcFunc-dddot -
1 950 )
782 ( "\\ddddot" calcFunc-ddddot -
1 950 )
783 ( "\\div" / 170 171 )
784 ( "\\le" calcFunc-leq
160 161 )
785 ( "\\leqq" calcFunc-leq
160 161 )
786 ( "\\leqsland" calcFunc-leq
160 161 )
787 ( "\\ge" calcFunc-geq
160 161 )
788 ( "\\geqq" calcFunc-geq
160 161 )
789 ( "\\geqslant" calcFunc-geq
160 161 )
790 ( "=" calcFunc-eq
160 161 )
791 ( "\\neq" calcFunc-neq
160 161 )
792 ( "\\ne" calcFunc-neq
160 161 )
793 ( "\\lnot" calcFunc-lnot -
1 121 )
794 ( "\\land" calcFunc-land
110 111 )
795 ( "\\lor" calcFunc-lor
100 101 )
796 ( "?" (math-read-if) 91 90 )
797 ( "!!!" calcFunc-pnot -
1 85 )
798 ( "&&&" calcFunc-pand
80 81 )
799 ( "|||" calcFunc-por
75 76 )
800 ( "\\gets" calcFunc-assign
51 50 )
801 ( ":=" calcFunc-assign
51 50 )
802 ( "::" calcFunc-condition
45 46 )
803 ( "\\to" calcFunc-evalto
40 41 )
804 ( "\\to" calcFunc-evalto
40 -
1 )
805 ( "=>" calcFunc-evalto
40 41 )
806 ( "=>" calcFunc-evalto
40 -
1 ))))
808 (put 'latex
'math-function-table
810 (get 'tex
'math-function-table
)
811 '(( \\frac .
(math-latex-parse-frac))
812 ( \\tfrac .
(math-latex-parse-frac))
813 ( \\dfrac .
(math-latex-parse-frac))
814 ( \\binom .
(math-latex-parse-two-args calcFunc-choose
))
815 ( \\tbinom .
(math-latex-parse-two-args calcFunc-choose
))
816 ( \\dbinom .
(math-latex-parse-two-args calcFunc-choose
))
817 ( \\phi . calcFunc-totient
)
818 ( \\mu . calcFunc-moebius
))))
820 (put 'latex
'math-special-function-table
821 '((/ .
(math-compose-latex-frac "\\frac"))
822 (calcFunc-choose .
(math-compose-latex-frac "\\binom"))
823 (calcFunc-sum .
(math-compose-tex-sum "\\sum"))
824 (calcFunc-prod .
(math-compose-tex-sum "\\prod"))
825 (calcFunc-sqrt . math-compose-tex-sqrt
)
826 (intv . math-compose-tex-intv
)))
828 (put 'latex
'math-variable-table
829 (get 'tex
'math-variable-table
))
831 (put 'latex
'math-punc-table
836 (put 'latex
'math-complex-format
'i
)
838 (put 'latex
'math-matrix-formatter
841 (if (and (integerp calc-language-option
)
842 (or (= calc-language-option
0)
843 (> calc-language-option
1)
844 (< calc-language-option -
1)))
845 (append '(vleft 0 "\\begin{pmatrix}")
846 (math-compose-tex-matrix (cdr a
) t
)
848 (append '(horiz "\\begin{pmatrix} ")
849 (math-compose-tex-matrix (cdr a
) t
)
850 '(" \\end{pmatrix}"))))))
852 (put 'latex
'math-var-formatter
'math-compose-tex-var
)
854 (put 'latex
'math-func-formatter
'math-compose-tex-func
)
856 (put 'latex
'math-dots
"\\ldots")
858 (put 'latex
'math-big-parens
'("\\left( " .
" \\right)"))
860 (put 'latex
'math-evalto
'("\\evalto " .
" \\to "))
862 (put 'latex
'math-lang-read-symbol
864 (< math-exp-pos
(1- (length math-exp-str
)))
866 (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
867 math-exp-str math-exp-pos
)
868 (string-match "\\\\text *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
869 math-exp-str math-exp-pos
)
870 (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)"
871 math-exp-str math-exp-pos
))
872 (setq math-exp-token
'symbol
873 math-exp-pos
(match-end 0)
874 math-expr-data
(math-restore-dashes
875 (math-match-substring math-exp-str
1)))
876 (let ((code (assoc math-expr-data math-tex-ignore-words
))
881 ((eq (nth 1 code
) 'punc
)
882 (setq math-exp-token
'punc
883 math-expr-data
(nth 2 code
)))
884 ((and (eq (nth 1 code
) 'begenv
)
885 (string-match " *{\\([^}]*\\)}" math-exp-str math-exp-pos
))
886 (setq math-exp-pos
(match-end 0)
887 envname
(match-string 1 math-exp-str
)
890 (cond ((or (string= envname
"matrix")
891 (string= envname
"bmatrix")
892 (string= envname
"smallmatrix")
893 (string= envname
"pmatrix"))
894 (if (string-match (concat "\\\\end{" envname
"}")
895 math-exp-str math-exp-pos
)
897 (replace-match "]" t t math-exp-str
))
898 (error "%s" (concat "No closing \\end{" envname
"}"))))))
899 ((and (eq (nth 1 code
) 'mat
)
900 (string-match " *{" math-exp-str math-exp-pos
))
901 (setq math-exp-pos
(match-end 0)
904 (let ((right (string-match "}" math-exp-str math-exp-pos
)))
906 (setq math-exp-str
(copy-sequence math-exp-str
))
907 (aset math-exp-str right ?\
]))))))))))
909 (defun math-latex-parse-frac (f val
)
911 (setq numer
(car (math-read-expr-list)))
913 (setq denom
(math-read-factor))
914 (if (and (Math-num-integerp numer
)
915 (Math-num-integerp denom
))
916 (list 'frac numer denom
)
917 (list '/ numer denom
))))
919 (defun math-latex-parse-two-args (f val
)
921 (setq first
(car (math-read-expr-list)))
923 (setq second
(math-read-factor))
924 (list (nth 2 f
) first second
)))
926 (defun math-compose-latex-frac (a fn
)
927 (list 'horiz
(nth 1 fn
) "{" (math-compose-expr (nth 1 a
) -
1)
929 (math-compose-expr (nth 2 a
) -
1)
932 (put 'latex
'math-input-filter
'math-tex-input-filter
)
934 (defun calc-eqn-language (n)
937 (calc-set-language 'eqn
)
938 (message "Eqn language mode")))
940 (put 'eqn
'math-oper-table
941 '( ( "prime" (math-parse-eqn-prime) 950 -
1 )
942 ( "prime" calcFunc-Prime
950 -
1 )
943 ( "dot" calcFunc-dot
950 -
1 )
944 ( "dotdot" calcFunc-dotdot
950 -
1 )
945 ( "hat" calcFunc-hat
950 -
1 )
946 ( "tilde" calcFunc-tilde
950 -
1 )
947 ( "vec" calcFunc-Vec
950 -
1 )
948 ( "dyad" calcFunc-dyad
950 -
1 )
949 ( "bar" calcFunc-bar
950 -
1 )
950 ( "under" calcFunc-under
950 -
1 )
951 ( "sub" calcFunc-subscr
931 930 )
953 ( "sqrt" calcFunc-sqrt -
1 910 )
955 ( "u|" calcFunc-abs -
1 0 )
957 ( "left floor" calcFunc-floor -
1 0 )
958 ( "right floor" closing
0 -
1 )
959 ( "left ceil" calcFunc-ceil -
1 0 )
960 ( "right ceil" closing
0 -
1 )
961 ( "+-" sdev
300 300 )
962 ( "!" calcFunc-fact
210 -
1 )
963 ( "u+" ident -
1 197 )
965 ( "times" * 191 190 )
972 ( "<" calcFunc-lt
160 161 )
973 ( ">" calcFunc-gt
160 161 )
974 ( "<=" calcFunc-leq
160 161 )
975 ( ">=" calcFunc-geq
160 161 )
976 ( "=" calcFunc-eq
160 161 )
977 ( "==" calcFunc-eq
160 161 )
978 ( "!=" calcFunc-neq
160 161 )
979 ( "u!" calcFunc-lnot -
1 121 )
980 ( "&&" calcFunc-land
110 111 )
981 ( "||" calcFunc-lor
100 101 )
982 ( "?" (math-read-if) 91 90 )
983 ( "!!!" calcFunc-pnot -
1 85 )
984 ( "&&&" calcFunc-pand
80 81 )
985 ( "|||" calcFunc-por
75 76 )
986 ( "<-" calcFunc-assign
51 50 )
987 ( ":=" calcFunc-assign
51 50 )
988 ( "::" calcFunc-condition
45 46 )
989 ( "->" calcFunc-evalto
40 41 )
990 ( "->" calcFunc-evalto
40 -
1 )
991 ( "=>" calcFunc-evalto
40 41 )
992 ( "=>" calcFunc-evalto
40 -
1 )))
994 (put 'eqn
'math-function-table
995 '( ( arc\ cos . calcFunc-arccos
)
996 ( arc\ cosh . calcFunc-arccosh
)
997 ( arc\ sin . calcFunc-arcsin
)
998 ( arc\ sinh . calcFunc-arcsinh
)
999 ( arc\ tan . calcFunc-arctan
)
1000 ( arc\ tanh . calcFunc-arctanh
)
1001 ( GAMMA . calcFunc-gamma
)
1002 ( phi . calcFunc-totient
)
1003 ( mu . calcFunc-moebius
)
1004 ( matrix .
(math-parse-eqn-matrix) )))
1006 (put 'eqn
'math-special-function-table
1007 '((intv . math-compose-eqn-intv
)))
1009 (put 'eqn
'math-punc-table
1013 (put 'eqn
'math-variable-table
1014 '( ( inf . var-uinf
)))
1016 (put 'eqn
'math-complex-format
'i
)
1018 (put 'eqn
'math-big-parens
'("{left ( " .
" right )}"))
1020 (put 'eqn
'math-evalto
'("evalto " .
" -> "))
1022 (put 'eqn
'math-matrix-formatter
1025 (append '(horiz "matrix { ")
1026 (math-compose-eqn-matrix
1027 (cdr (math-transpose a
)))
1030 (put 'eqn
'math-var-formatter
1034 (if (and math-compose-hash-args
1035 (let ((p calc-arg-values
))
1037 (while (and p
(not (equal (car p
) a
)))
1038 (setq p
(and (eq math-compose-hash-args t
) (cdr p
))
1041 (if (eq math-compose-hash-args
1)
1044 (if (string-match ".'\\'" (symbol-name (nth 2 a
)))
1046 (list 'calcFunc-Prime
1049 (intern (substring (symbol-name (nth 1 a
)) 0 -
1))
1050 (intern (substring (symbol-name (nth 2 a
)) 0 -
1))))
1052 (symbol-name (nth 1 a
))))))))
1054 (defconst math-eqn-special-funcs
1056 calcFunc-ln calcFunc-exp
1057 calcFunc-sin calcFunc-cos calcFunc-tan
1058 calcFunc-sec calcFunc-csc calcFunc-cot
1059 calcFunc-sinh calcFunc-cosh calcFunc-tanh
1060 calcFunc-sech calcFunc-csch calcFunc-coth
1061 calcFunc-arcsin calcFunc-arccos calcFunc-arctan
1062 calcFunc-arcsinh calcFunc-arccosh calcFunc-arctanh
))
1064 (put 'eqn
'math-func-formatter
1068 (if (string-match "[^']'+\\'" func
)
1069 (let ((n (- (length func
) (match-beginning 0) 1)))
1070 (setq func
(substring func
0 (- n
)))
1071 (while (>= (setq n
(1- n
)) 0)
1072 (setq func
(concat func
" prime")))))
1073 (cond ((or (> (length a
) 2)
1074 (not (math-tex-expr-is-flat (nth 1 a
))))
1075 (setq left
"{left ( "
1079 (memq (car a
) math-eqn-special-funcs
)
1081 (or (Math-realp (nth 1 a
))
1082 (memq (car (nth 1 a
)) '(var *))))
1083 (setq left
"~{" right
"}"))
1087 (list 'horiz func left
1088 (math-compose-vector (cdr a
) " , " 0)
1091 (put 'eqn
'math-lang-read-symbol
1093 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)"
1094 math-exp-str math-exp-pos
)
1096 (setq math-exp-str
(copy-sequence math-exp-str
))
1097 (aset math-exp-str
(match-beginning 1) ?\
{)
1098 (if (< (match-end 1) (length math-exp-str
))
1099 (aset math-exp-str
(match-end 1) ?\
}))
1100 (math-read-token)))))
1102 (defconst math-eqn-ignore-words
1103 '( ("roman") ("bold") ("italic") ("mark") ("lineup") ("evalto")
1104 ("left" ("floor") ("ceil"))
1105 ("right" ("floor") ("ceil"))
1106 ("arc" ("sin") ("cos") ("tan") ("sinh") ("cosh") ("tanh"))
1107 ("size" n
) ("font" n
) ("fwd" n
) ("back" n
) ("up" n
) ("down" n
)
1108 ("above" punc
",")))
1110 (put 'eqn
'math-lang-adjust-words
1113 (let ((code (assoc math-expr-data math-eqn-ignore-words
)))
1117 ((consp (nth 1 code
))
1119 (if (assoc math-expr-data
(cdr code
))
1120 (setq math-expr-data
(format "%s %s"
1121 (car code
) math-expr-data
))))
1122 ((eq (nth 1 code
) 'punc
)
1123 (setq math-exp-token
'punc
1124 math-expr-data
(nth 2 code
)))
1127 (math-read-token)))))))
1129 (put 'eqn
'math-lang-read
1130 '((eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^"
1131 math-exp-str math-exp-pos
)
1134 (setq math-exp-token
'punc
1135 math-expr-data
(math-match-substring math-exp-str
0)
1136 math-exp-pos
(match-end 0))
1137 (and (eq (string-match "\\\\dots\\." math-exp-str math-exp-pos
)
1139 (setq math-exp-pos
(match-end 0)))
1140 (if (memq (aref math-expr-data
0) '(?~ ?^
))
1141 (math-read-token)))))
1144 (defun math-compose-eqn-matrix (a)
1147 (cond ((eq calc-matrix-just
'right
) "rcol ")
1148 ((eq calc-matrix-just
'center
) "ccol ")
1151 (list 'break math-compose-level
)
1155 (let ((math-compose-level (1+ math-compose-level
)))
1156 (math-compose-vector (cdr (car a
)) " above " 1000))
1159 (math-compose-eqn-matrix (cdr a
)))))))
1162 (defun math-parse-eqn-matrix (f sym
)
1164 (while (assoc math-expr-data
'(("ccol") ("lcol") ("rcol")))
1166 (or (equal math-expr-data calc-function-open
)
1167 (throw 'syntax
"Expected `{'"))
1169 (setq vec
(cons (cons 'vec
(math-read-expr-list)) vec
))
1170 (or (equal math-expr-data calc-function-close
)
1171 (throw 'syntax
"Expected `}'"))
1173 (or (equal math-expr-data calc-function-close
)
1174 (throw 'syntax
"Expected `}'"))
1176 (math-transpose (cons 'vec
(nreverse vec
)))))
1178 (defun math-parse-eqn-prime (x sym
)
1179 (if (eq (car-safe x
) 'var
)
1180 (if (equal math-expr-data calc-function-open
)
1183 (let ((args (if (or (equal math-expr-data calc-function-close
)
1184 (eq math-exp-token
'end
))
1186 (math-read-expr-list))))
1187 (if (not (or (equal math-expr-data calc-function-close
)
1188 (eq math-exp-token
'end
)))
1189 (throw 'syntax
"Expected `)'"))
1191 (cons (intern (format "calcFunc-%s'" (nth 1 x
))) args
)))
1193 (intern (concat (symbol-name (nth 1 x
)) "'"))
1194 (intern (concat (symbol-name (nth 2 x
)) "'"))))
1195 (list 'calcFunc-Prime x
)))
1197 (defun math-compose-eqn-intv (a)
1199 (if (memq (nth 1 a
) '(0 1)) "(" "[")
1200 (math-compose-expr (nth 2 a
) 0)
1202 (math-compose-expr (nth 3 a
) 0)
1203 (if (memq (nth 1 a
) '(0 2)) ")" "]")))
1208 (defun calc-yacas-language ()
1209 "Change the Calc language to be Yacas-like."
1212 (calc-set-language 'yacas
)
1213 (message "Yacas language mode")))
1215 (put 'yacas
'math-vector-brackets
"{}")
1217 (put 'yacas
'math-complex-format
'I
)
1219 (add-to-list 'calc-lang-brackets-are-subscripts
'yacas
)
1221 (put 'yacas
'math-variable-table
1222 '(( Infinity . var-inf
)
1223 ( Infinity . var-uinf
)
1224 ( Undefined . var-nan
)
1226 ( E . var-e
) ;; Not really in Yacas
1227 ( GoldenRatio . var-phi
)
1228 ( Gamma . var-gamma
)))
1230 (put 'yacas
'math-parse-table
1231 '((("Deriv(" 0 ")" 0)
1232 calcFunc-deriv
(var ArgB var-ArgB
) (var ArgA var-ArgA
))
1234 calcFunc-deriv
(var ArgB var-ArgB
) (var ArgA var-ArgA
))
1235 (("Integrate(" 0 ")" 0)
1236 calcFunc-integ
(var ArgB var-ArgB
)(var ArgA var-ArgA
))
1237 (("Integrate(" 0 "," 0 "," 0 ")" 0)
1238 calcFunc-integ
(var ArgD var-ArgD
) (var ArgA var-ArgA
)
1239 (var ArgB var-ArgB
) (var ArgC var-ArgC
))
1240 (("Subst(" 0 "," 0 ")" 0)
1241 calcFunc-subst
(var ArgC var-ArgC
) (var ArgA var-ArgA
)
1242 (var ArgB var-ArgB
))
1243 (("Taylor(" 0 "," 0 "," 0 ")" 0)
1244 calcFunc-taylor
(var ArgD var-ArgD
)
1245 (calcFunc-eq (var ArgA var-ArgA
) (var ArgB var-ArgB
))
1246 (var ArgC var-ArgC
))))
1248 (put 'yacas
'math-oper-table
1256 ("<<" calcFunc-lsh
80 80)
1257 (">>" calcFunc-rsh
80 80)
1258 ("!" calcFunc-fact
80 -
1)
1259 ("!!" calcFunc-dfact
80 -
1)
1260 ("X" calcFunc-cross
70 70)
1261 ("=" calcFunc-eq
10 10)
1262 ("!=" calcFunc-neq
10 10)
1263 ("<" calcFunc-lt
10 10)
1264 (">" calcFunc-gt
10 10)
1265 ("<=" calcFunc-leq
10 10)
1266 (">=" calcFunc-geq
10 10)
1267 ("And" calcFunc-land
5 5)
1268 ("Or" calcFunc-or
4 4)
1269 ("Not" calcFunc-lnot -
1 3)
1270 (":=" calcFunc-assign
1 1)))
1272 (put 'yacas
'math-function-table
1273 '(( Div . calcFunc-idiv
)
1274 ( Mod . calcFunc-mod
)
1275 ( Abs . calcFunc-abs
)
1276 ( Sign . calcFunc-sign
)
1277 ( Sqrt . calcFunc-sqrt
)
1278 ( Max . calcFunc-max
)
1279 ( Min . calcFunc-min
)
1280 ( Floor . calcFunc-floor
)
1281 ( Ceil . calcFunc-ceil
)
1282 ( Round . calcFunc-round
)
1283 ( Conjugate . calcFunc-conj
)
1284 ( Arg . calcFunc-arg
)
1287 ( Rationalize . calcFunc-pfrac
)
1288 ( Sin . calcFunc-sin
)
1289 ( Cos . calcFunc-cos
)
1290 ( Tan . calcFunc-tan
)
1291 ( Sec . calcFunc-sec
)
1292 ( Csc . calcFunc-csc
)
1293 ( Cot . calcFunc-cot
)
1294 ( ArcSin . calcFunc-arcsin
)
1295 ( ArcCos . calcFunc-arccos
)
1296 ( ArcTan . calcFunc-arctan
)
1297 ( Sinh . calcFunc-sinh
)
1298 ( Cosh . calcFunc-cosh
)
1299 ( Tanh . calcFunc-tanh
)
1300 ( Sech . calcFunc-sech
)
1301 ( Csch . calcFunc-csch
)
1302 ( Coth . calcFunc-coth
)
1303 ( ArcSinh . calcFunc-arcsinh
)
1304 ( ArcCosh . calcFunc-arccosh
)
1305 ( ArcTanh . calcFunc-arctanh
)
1307 ( Exp . calcFunc-exp
)
1308 ( Gamma . calcFunc-gamma
)
1309 ( Gcd . calcFunc-gcd
)
1310 ( Lcm . calcFunc-lcm
)
1311 ( Bin . calcFunc-choose
)
1312 ( Bernoulli . calcFunc-bern
)
1313 ( Euler . calcFunc-euler
)
1314 ( StirlingNumber1 . calcFunc-stir1
)
1315 ( StirlingNumber2 . calcFunc-stir2
)
1316 ( IsPrime . calcFunc-prime
)
1317 ( Factors . calcFunc-prfac
)
1318 ( NextPrime . calcFunc-nextprime
)
1319 ( Moebius . calcFunc-moebius
)
1320 ( Random . calcFunc-random
)
1321 ( Concat . calcFunc-vconcat
)
1322 ( Head . calcFunc-head
)
1323 ( Tail . calcFunc-tail
)
1324 ( Length . calcFunc-vlen
)
1325 ( Reverse . calcFunc-rev
)
1326 ( CrossProduct . calcFunc-cross
)
1327 ( Dot . calcFunc-mul
)
1328 ( DiagonalMatrix . calcFunc-diag
)
1329 ( Transpose . calcFunc-trn
)
1330 ( Inverse . calcFunc-inv
)
1331 ( Determinant . calcFunc-det
)
1332 ( Trace . calcFunc-tr
)
1333 ( RemoveDuplicates . calcFunc-rdup
)
1334 ( Union . calcFunc-vunion
)
1335 ( Intersection . calcFunc-vint
)
1336 ( Difference . calcFunc-vdiff
)
1337 ( Apply . calcFunc-apply
)
1338 ( Map . calcFunc-map
)
1339 ( Simplify . calcFunc-simplify
)
1340 ( ExpandBrackets . calcFunc-expand
)
1341 ( Solve . calcFunc-solve
)
1342 ( Degree . calcFunc-pdeg
)
1344 ( Contains .
(math-lang-switch-args calcFunc-in
))
1345 ( Sum .
(math-yacas-parse-Sum calcFunc-sum
))
1346 ( Factorize .
(math-yacas-parse-Sum calcFunc-prod
))))
1348 (put 'yacas
'math-special-function-table
1349 '(( calcFunc-sum .
(math-yacas-compose-sum "Sum"))
1350 ( calcFunc-prod .
(math-yacas-compose-sum "Factorize"))
1351 ( calcFunc-deriv .
(math-yacas-compose-deriv "Deriv"))
1352 ( calcFunc-integ .
(math-yacas-compose-deriv "Integrate"))
1353 ( calcFunc-taylor . math-yacas-compose-taylor
)
1354 ( calcFunc-in .
(math-lang-compose-switch-args "Contains"))))
1356 (put 'yacas
'math-compose-subscr
1359 (let ((args (cdr (cdr a
))))
1361 (math-compose-expr (nth 1 a
) 1000)
1363 (math-compose-vector args
", " 0)
1366 (defun math-yacas-parse-Sum (f val
)
1367 "Read in the arguments to \"Sum\" in Calc's Yacas mode."
1368 (let ((args (math-read-expr-list)))
1376 (defun math-yacas-compose-sum (a fn
)
1377 "Compose the \"Sum\" function in Calc's Yacas mode."
1381 (math-compose-expr (nth 2 a
) -
1)
1383 (math-compose-expr (nth 3 a
) -
1)
1385 (math-compose-expr (nth 4 a
) -
1)
1387 (math-compose-expr (nth 1 a
) -
1)
1390 (defun math-yacas-compose-deriv (a fn
)
1391 "Compose the \"Deriv\" function in Calc's Yacas mode."
1395 (math-compose-expr (nth 2 a
) -
1)
1400 (math-compose-expr (nth 3 a
) -
1)
1402 (math-compose-expr (nth 4 a
) -
1)
1405 (math-compose-expr (nth 1 a
) -
1)))
1407 (defun math-yacas-compose-taylor (a)
1408 "Compose the \"Taylor\" function in Calc's Yacas mode."
1411 (if (eq (car-safe (nth 2 a
)) 'calcFunc-eq
)
1412 (concat (math-compose-expr (nth 1 (nth 2 a
)) -
1)
1414 (math-compose-expr (nth 2 (nth 2 a
)) -
1))
1415 (concat (math-compose-expr (nth 2 a
) -
1) ",0"))
1417 (math-compose-expr (nth 3 a
) -
1)
1419 (math-compose-expr (nth 1 a
) -
1)))
1424 (defun calc-maxima-language ()
1425 "Change the Calc language to be Maxima-like."
1428 (calc-set-language 'maxima
)
1429 (message "Maxima language mode")))
1431 (put 'maxima
'math-oper-table
1441 ("!" calcFunc-fact
160 -
1)
1442 ("!!" calcFunc-dfact
160 -
1)
1443 ("=" calcFunc-eq
80 80)
1444 ("#" calcFunc-neq
80 80)
1445 ("<" calcFunc-lt
80 80)
1446 (">" calcFunc-gt
80 80)
1447 ("<=" calcFunc-leq
80 80)
1448 (">=" calcFunc-geq
80 80)
1449 ("and" calcFunc-land
65 65)
1450 ("or" calcFunc-or
60 60)
1451 ("not" calcFunc-lnot -
1 70)
1452 (":" calcFunc-assign
180 20)))
1455 (put 'maxima
'math-function-table
1457 ( abs . calcFunc-abs
)
1458 ( cabs . calcFunc-abs
)
1459 ( signum . calcFunc-sign
)
1460 ( floor . calcFunc-floor
)
1461 ( entier . calcFunc-floor
)
1462 ( fix . calcFunc-floor
)
1463 ( conjugate . calcFunc-conj
)
1464 ( carg . calcFunc-arg
)
1465 ( realpart . calcFunc-re
)
1466 ( imagpart . calcFunc-im
)
1467 ( rationalize . calcFunc-pfrac
)
1468 ( asin . calcFunc-arcsin
)
1469 ( acos . calcFunc-arccos
)
1470 ( atan . calcFunc-arctan
)
1471 ( atan2 . calcFunc-arctan2
)
1472 ( asinh . calcFunc-arcsinh
)
1473 ( acosh . calcFunc-arccosh
)
1474 ( atanh . calcFunc-arctanh
)
1475 ( log . calcFunc-ln
)
1476 ( plog . calcFunc-ln
)
1477 ( bessel_j . calcFunc-besJ
)
1478 ( bessel_y . calcFunc-besY
)
1479 ( factorial . calcFunc-fact
)
1480 ( binomial . calcFunc-choose
)
1481 ( primep . calcFunc-prime
)
1482 ( next_prime . calcFunc-nextprime
)
1483 ( prev_prime . calcFunc-prevprime
)
1484 ( append . calcFunc-vconcat
)
1485 ( rest . calcFunc-tail
)
1486 ( reverse . calcFunc-rev
)
1487 ( innerproduct . calcFunc-mul
)
1488 ( inprod . calcFunc-mul
)
1489 ( row . calcFunc-mrow
)
1490 ( columnvector . calcFunc-mcol
)
1491 ( covect . calcFunc-mcol
)
1492 ( transpose . calcFunc-trn
)
1493 ( invert . calcFunc-inv
)
1494 ( determinant . calcFunc-det
)
1495 ( mattrace . calcFunc-tr
)
1496 ( member . calcFunc-in
)
1497 ( lmax . calcFunc-vmax
)
1498 ( lmin . calcFunc-vmin
)
1499 ( distrib . calcFunc-expand
)
1500 ( partfrac . calcFunc-apart
)
1501 ( rat . calcFunc-nrat
)
1502 ( product . calcFunc-prod
)
1503 ( diff . calcFunc-deriv
)
1504 ( integrate . calcFunc-integ
)
1505 ( quotient . calcFunc-pdiv
)
1506 ( remainder . calcFunc-prem
)
1507 ( divide . calcFunc-pdivrem
)
1508 ( equal . calcFunc-eq
)
1509 ( notequal . calcFunc-neq
)
1510 ( rhs . calcFunc-rmeq
)
1511 ( subst .
(math-maxima-parse-subst))
1512 ( substitute .
(math-maxima-parse-subst))
1513 ( taylor .
(math-maxima-parse-taylor))))
1515 (defun math-maxima-parse-subst (f val
)
1516 "Read in the arguments to \"subst\" in Calc's Maxima mode."
1517 (let ((args (math-read-expr-list)))
1519 (list 'calcFunc-subst
1524 (defun math-maxima-parse-taylor (f val
)
1525 "Read in the arguments to \"taylor\" in Calc's Maxima mode."
1526 (let ((args (math-read-expr-list)))
1528 (list 'calcFunc-taylor
1535 (put 'maxima
'math-parse-table
1536 '((("if" 0 "then" 0 "else" 0)
1540 (var ArgC var-ArgC
))))
1542 (put 'maxima
'math-special-function-table
1543 '(( calcFunc-taylor . math-maxima-compose-taylor
)
1544 ( calcFunc-subst . math-maxima-compose-subst
)
1545 ( calcFunc-if . math-maxima-compose-if
)))
1547 (defun math-maxima-compose-taylor (a)
1548 "Compose the \"taylor\" function in Calc's Maxima mode."
1551 (math-compose-expr (nth 1 a
) -
1)
1553 (if (eq (car-safe (nth 2 a
)) 'calcFunc-eq
)
1554 (concat (math-compose-expr (nth 1 (nth 2 a
)) -
1)
1556 (math-compose-expr (nth 2 (nth 2 a
)) -
1))
1557 (concat (math-compose-expr (nth 2 a
) -
1) ",0"))
1559 (math-compose-expr (nth 3 a
) -
1)
1562 (defun math-maxima-compose-subst (a)
1563 "Compose the \"subst\" function in Calc's Maxima mode."
1566 (math-compose-expr (nth 2 a
) -
1)
1568 (math-compose-expr (nth 3 a
) -
1)
1570 (math-compose-expr (nth 1 a
) -
1)
1573 (defun math-maxima-compose-if (a)
1574 "Compose the \"if\" function in Calc's Maxima mode."
1577 (math-compose-expr (nth 1 a
) -
1)
1579 (math-compose-expr (nth 2 a
) -
1)
1581 (math-compose-expr (nth 3 a
) -
1)))
1583 (put 'maxima
'math-variable-table
1584 '(( infinity . var-uinf
)
1589 ( %gamma . var-gamma
)))
1591 (put 'maxima
'math-complex-format
'%i
)
1593 (add-to-list 'calc-lang-allow-underscores
'maxima
)
1595 (add-to-list 'calc-lang-allow-percentsigns
'maxima
)
1597 (add-to-list 'calc-lang-brackets-are-subscripts
'maxima
)
1599 (put 'maxima
'math-compose-subscr
1602 (let ((args (cdr (cdr a
))))
1604 (math-compose-expr (nth 1 a
) 1000)
1606 (math-compose-vector args
", " 0)
1609 (put 'maxima
'math-matrix-formatter
1614 (math-compose-vector (cdr a
)
1615 (concat math-comp-comma
" ")
1616 math-comp-vector-prec
)
1622 (defun calc-giac-language ()
1623 "Change the Calc language to be Giac-like."
1626 (calc-set-language 'giac
)
1627 (message "Giac language mode")))
1629 (put 'giac
'math-oper-table
1630 '( ( "[" (math-read-giac-subscr) 250 -
1 )
1636 ( "u+" ident -
1 197 )
1638 ( "!" calcFunc-fact
210 -
1 )
1639 ( ".." (math-read-maple-dots) 165 165 )
1640 ( "\\dots" (math-read-maple-dots) 165 165 )
1641 ( "intersect" calcFunc-vint
191 192 )
1642 ( "union" calcFunc-vunion
180 181 )
1643 ( "minus" calcFunc-vdiff
180 181 )
1644 ( "<" calcFunc-lt
160 160 )
1645 ( ">" calcFunc-gt
160 160 )
1646 ( "<=" calcFunc-leq
160 160 )
1647 ( ">=" calcFunc-geq
160 160 )
1648 ( "=" calcFunc-eq
160 160 )
1649 ( "==" calcFunc-eq
160 160 )
1650 ( "!=" calcFunc-neq
160 160 )
1651 ( "and" calcFunc-land
110 111 )
1652 ( "or" calcFunc-lor
100 101 )
1653 ( "&&" calcFunc-land
110 111 )
1654 ( "||" calcFunc-lor
100 101 )
1655 ( "not" calcFunc-lnot -
1 121 )
1656 ( ":=" calcFunc-assign
51 50 )))
1659 (put 'giac
'math-function-table
1660 '(( rdiv . calcFunc-div
)
1661 ( iquo . calcFunc-idiv
)
1662 ( irem . calcFunc-mod
)
1663 ( remain . calcFunc-mod
)
1664 ( floor . calcFunc-floor
)
1665 ( iPart . calcFunc-floor
)
1666 ( ceil . calcFunc-ceil
)
1667 ( ceiling . calcFunc-ceil
)
1669 ( real . calcFunc-re
)
1671 ( imag . calcFunc-im
)
1672 ( float2rational . calcFunc-pfrac
)
1673 ( exact . calcFunc-pfrac
)
1674 ( evalf . calcFunc-pfloat
)
1675 ( bitand . calcFunc-and
)
1676 ( bitor . calcFunc-or
)
1677 ( bitxor . calcFunc-xor
)
1678 ( asin . calcFunc-arcsin
)
1679 ( acos . calcFunc-arccos
)
1680 ( atan . calcFunc-arctan
)
1681 ( asinh . calcFunc-arcsinh
)
1682 ( acosh . calcFunc-arccosh
)
1683 ( atanh . calcFunc-arctanh
)
1684 ( log . calcFunc-ln
)
1685 ( logb . calcFunc-log
)
1686 ( factorial . calcFunc-fact
)
1687 ( comb . calcFunc-choose
)
1688 ( binomial . calcFunc-choose
)
1689 ( nCr . calcFunc-choose
)
1690 ( perm . calcFunc-perm
)
1691 ( nPr . calcFunc-perm
)
1692 ( bernoulli . calcFunc-bern
)
1693 ( is_prime . calcFunc-prime
)
1694 ( isprime . calcFunc-prime
)
1695 ( isPrime . calcFunc-prime
)
1696 ( ifactors . calcFunc-prfac
)
1697 ( euler . calcFunc-totient
)
1698 ( phi . calcFunc-totient
)
1699 ( rand . calcFunc-random
)
1700 ( concat . calcFunc-vconcat
)
1701 ( augment . calcFunc-vconcat
)
1702 ( mid . calcFunc-subvec
)
1703 ( length . calcFunc-length
)
1704 ( size . calcFunc-length
)
1705 ( nops . calcFunc-length
)
1706 ( SortA . calcFunc-sort
)
1707 ( SortB . calcFunc-rsort
)
1708 ( revlist . calcFunc-rev
)
1709 ( cross . calcFunc-cross
)
1710 ( crossP . calcFunc-cross
)
1711 ( crossproduct . calcFunc-cross
)
1712 ( mul . calcFunc-mul
)
1713 ( dot . calcFunc-mul
)
1714 ( dotprod . calcFunc-mul
)
1715 ( dotP . calcFunc-mul
)
1716 ( scalar_product . calcFunc-mul
)
1717 ( scalar_Product . calcFunc-mul
)
1718 ( row . calcFunc-mrow
)
1719 ( col . calcFunc-mcol
)
1720 ( dim . calcFunc-mdims
)
1721 ( tran . calcFunc-trn
)
1722 ( transpose . calcFunc-trn
)
1723 ( lu . calcFunc-lud
)
1724 ( trace . calcFunc-tr
)
1725 ( member . calcFunc-in
)
1726 ( sum . calcFunc-vsum
)
1727 ( add . calcFunc-vsum
)
1728 ( product . calcFunc-vprod
)
1729 ( mean . calcFunc-vmean
)
1730 ( median . calcFunc-vmedian
)
1731 ( stddev . calcFunc-vsdev
)
1732 ( stddevp . calcFunc-vpsdev
)
1733 ( variance . calcFunc-vpvar
)
1734 ( map . calcFunc-map
)
1735 ( apply . calcFunc-map
)
1736 ( of . calcFunc-map
)
1737 ( zip . calcFunc-map
)
1738 ( expand . calcFunc-expand
)
1739 ( fdistrib . calcFunc-expand
)
1740 ( partfrac . calcFunc-apart
)
1741 ( ratnormal . calcFunc-nrat
)
1742 ( diff . calcFunc-deriv
)
1743 ( derive . calcFunc-deriv
)
1744 ( integrate . calcFunc-integ
)
1745 ( int . calcFunc-integ
)
1746 ( Int . calcFunc-integ
)
1747 ( romberg . calcFunc-ninteg
)
1748 ( nInt . calcFunc-ninteg
)
1749 ( lcoeff . calcFunc-plead
)
1750 ( content . calcFunc-pcont
)
1751 ( primpart . calcFunc-pprim
)
1752 ( quo . calcFunc-pdiv
)
1753 ( rem . calcFunc-prem
)
1754 ( quorem . calcFunc-pdivrem
)
1755 ( divide . calcFunc-pdivrem
)
1756 ( equal . calcFunc-eq
)
1757 ( ifte . calcFunc-if
)
1758 ( not . calcFunc-lnot
)
1759 ( rhs . calcFunc-rmeq
)
1760 ( right . calcFunc-rmeq
)
1761 ( prepend .
(math-lang-switch-args calcFunc-cons
))
1762 ( contains .
(math-lang-switch-args calcFunc-in
))
1763 ( has .
(math-lang-switch-args calcFunc-refers
))))
1765 (defun math-lang-switch-args (f val
)
1766 "Read the arguments to a Calc function in reverse order.
1767 This is used for various language modes which have functions in reverse
1769 (let ((args (math-read-expr-list)))
1775 (put 'giac
'math-parse-table
1778 (var ArgA var-ArgA
))))
1780 (put 'giac
'math-special-function-table
1781 '((calcFunc-cons .
(math-lang-compose-switch-args "prepend"))
1782 (calcFunc-in .
(math-lang-compose-switch-args "contains"))
1783 (calcFunc-refers .
(math-lang-compose-switch-args "has"))
1784 (intv . math-compose-maple-intv
)))
1786 (defun math-lang-compose-switch-args (a fn
)
1787 "Compose the arguments to a Calc function in reverse order.
1788 This is used for various language modes which have functions in reverse
1790 (list 'horiz
(nth 1 fn
)
1792 (math-compose-expr (nth 2 a
) 0)
1794 (math-compose-expr (nth 1 a
) 0)
1797 (put 'giac
'math-variable-table
1798 '(( infinity . var-inf
)
1799 ( infinity . var-uinf
)))
1801 (put 'giac
'math-complex-format
'i
)
1803 (add-to-list 'calc-lang-allow-underscores
'giac
)
1805 (put 'giac
'math-compose-subscr
1808 (let ((args (cdr (cdr a
))))
1810 (math-compose-expr (nth 1 a
) 1000)
1813 (calc-normalize (list '-
(nth 2 a
) 1)) 0)
1816 (defun math-read-giac-subscr (x op
)
1817 (let ((idx (math-read-expr-level 0)))
1818 (or (equal math-expr-data
"]")
1819 (throw 'syntax
"Expected `]'"))
1821 (list 'calcFunc-subscr x
(calc-normalize (list '+ idx
1)))))
1823 (add-to-list 'calc-lang-c-type-hex
'giac
)
1826 (defun calc-mathematica-language ()
1829 (calc-set-language 'math
)
1830 (message "Mathematica language mode")))
1832 (put 'math
'math-oper-table
1833 '( ( "[[" (math-read-math-subscr) 250 -
1 )
1834 ( "!" calcFunc-fact
210 -
1 )
1835 ( "!!" calcFunc-dfact
210 -
1 )
1837 ( "u+" ident -
1 197 )
1844 ( "<" calcFunc-lt
160 161 )
1845 ( ">" calcFunc-gt
160 161 )
1846 ( "<=" calcFunc-leq
160 161 )
1847 ( ">=" calcFunc-geq
160 161 )
1848 ( "==" calcFunc-eq
150 151 )
1849 ( "!=" calcFunc-neq
150 151 )
1850 ( "u!" calcFunc-lnot -
1 121 )
1851 ( "&&" calcFunc-land
110 111 )
1852 ( "||" calcFunc-lor
100 101 )
1853 ( "!!!" calcFunc-pnot -
1 85 )
1854 ( "&&&" calcFunc-pand
80 81 )
1855 ( "|||" calcFunc-por
75 76 )
1856 ( ":=" calcFunc-assign
51 50 )
1857 ( "=" calcFunc-assign
51 50 )
1858 ( "->" calcFunc-assign
51 50 )
1859 ( ":>" calcFunc-assign
51 50 )
1860 ( "::" calcFunc-condition
45 46 )
1863 (put 'math
'math-function-table
1864 '( ( Abs . calcFunc-abs
)
1865 ( ArcCos . calcFunc-arccos
)
1866 ( ArcCosh . calcFunc-arccosh
)
1867 ( ArcSin . calcFunc-arcsin
)
1868 ( ArcSinh . calcFunc-arcsinh
)
1869 ( ArcTan . calcFunc-arctan
)
1870 ( ArcTanh . calcFunc-arctanh
)
1871 ( Arg . calcFunc-arg
)
1872 ( Binomial . calcFunc-choose
)
1873 ( Ceiling . calcFunc-ceil
)
1874 ( Conjugate . calcFunc-conj
)
1875 ( Cos . calcFunc-cos
)
1876 ( Cosh . calcFunc-cosh
)
1877 ( Cot . calcFunc-cot
)
1878 ( Coth . calcFunc-coth
)
1879 ( Csc . calcFunc-csc
)
1880 ( Csch . calcFunc-csch
)
1881 ( D . calcFunc-deriv
)
1882 ( Dt . calcFunc-tderiv
)
1883 ( Det . calcFunc-det
)
1884 ( Exp . calcFunc-exp
)
1885 ( EulerPhi . calcFunc-totient
)
1886 ( Floor . calcFunc-floor
)
1887 ( Gamma . calcFunc-gamma
)
1888 ( GCD . calcFunc-gcd
)
1889 ( If . calcFunc-if
)
1890 ( Im . calcFunc-im
)
1891 ( Inverse . calcFunc-inv
)
1892 ( Integrate . calcFunc-integ
)
1893 ( Join . calcFunc-vconcat
)
1894 ( LCM . calcFunc-lcm
)
1895 ( Log . calcFunc-ln
)
1896 ( Max . calcFunc-max
)
1897 ( Min . calcFunc-min
)
1898 ( Mod . calcFunc-mod
)
1899 ( MoebiusMu . calcFunc-moebius
)
1900 ( Random . calcFunc-random
)
1901 ( Round . calcFunc-round
)
1902 ( Re . calcFunc-re
)
1903 ( Sec . calcFunc-sec
)
1904 ( Sech . calcFunc-sech
)
1905 ( Sign . calcFunc-sign
)
1906 ( Sin . calcFunc-sin
)
1907 ( Sinh . calcFunc-sinh
)
1908 ( Sqrt . calcFunc-sqrt
)
1909 ( Tan . calcFunc-tan
)
1910 ( Tanh . calcFunc-tanh
)
1911 ( Transpose . calcFunc-trn
)
1912 ( Length . calcFunc-vlen
)
1915 (put 'math
'math-variable-table
1919 ( GoldenRatio . var-phi
)
1920 ( EulerGamma . var-gamma
)
1921 ( Infinity . var-inf
)
1922 ( ComplexInfinity . var-uinf
)
1923 ( Indeterminate . var-nan
)
1926 (put 'math
'math-vector-brackets
"{}")
1927 (put 'math
'math-complex-format
'I
)
1928 (put 'math
'math-function-open
"[")
1929 (put 'math
'math-function-close
"]")
1931 (put 'math
'math-radix-formatter
1932 (function (lambda (r s
) (format "%d^^%s" r s
))))
1934 (put 'math
'math-lang-read
1935 '((eq (string-match "\\[\\[\\|->\\|:>" math-exp-str math-exp-pos
)
1937 (setq math-exp-token
'punc
1938 math-expr-data
(math-match-substring math-exp-str
0)
1939 math-exp-pos
(match-end 0))))
1941 (put 'math
'math-compose-subscr
1945 (math-compose-expr (nth 1 a
) 1000)
1947 (math-compose-expr (nth 2 a
) 0)
1950 (defun math-read-math-subscr (x op
)
1951 (let ((idx (math-read-expr-level 0)))
1952 (or (and (equal math-expr-data
"]")
1955 (equal math-expr-data
"]")))
1956 (throw 'syntax
"Expected `]]'"))
1958 (list 'calcFunc-subscr x idx
)))
1961 (defun calc-maple-language ()
1964 (calc-set-language 'maple
)
1965 (message "Maple language mode")))
1967 (put 'maple
'math-oper-table
1968 '( ( "matrix" ident -
1 300 )
1969 ( "MATRIX" ident -
1 300 )
1970 ( "!" calcFunc-fact
210 -
1 )
1973 ( "u+" ident -
1 197 )
1977 ( "intersect" calcFunc-vint
191 192 )
1980 ( "union" calcFunc-vunion
180 181 )
1981 ( "minus" calcFunc-vdiff
180 181 )
1983 ( ".." (math-read-maple-dots) 165 165 )
1984 ( "\\dots" (math-read-maple-dots) 165 165 )
1985 ( "<" calcFunc-lt
160 160 )
1986 ( ">" calcFunc-gt
160 160 )
1987 ( "<=" calcFunc-leq
160 160 )
1988 ( ">=" calcFunc-geq
160 160 )
1989 ( "=" calcFunc-eq
160 160 )
1990 ( "<>" calcFunc-neq
160 160 )
1991 ( "not" calcFunc-lnot -
1 121 )
1992 ( "and" calcFunc-land
110 111 )
1993 ( "or" calcFunc-lor
100 101 )
1994 ( "!!!" calcFunc-pnot -
1 85 )
1995 ( "&&&" calcFunc-pand
80 81 )
1996 ( "|||" calcFunc-por
75 76 )
1997 ( ":=" calcFunc-assign
51 50 )
1998 ( "::" calcFunc-condition
45 46 )
2001 (put 'maple
'math-function-table
2002 '( ( bernoulli . calcFunc-bern
)
2003 ( binomial . calcFunc-choose
)
2004 ( diff . calcFunc-deriv
)
2005 ( GAMMA . calcFunc-gamma
)
2006 ( ifactor . calcFunc-prfac
)
2007 ( igcd . calcFunc-gcd
)
2008 ( ilcm . calcFunc-lcm
)
2009 ( int . calcFunc-integ
)
2012 ( iquo . calcFunc-idiv
)
2013 ( isprime . calcFunc-prime
)
2014 ( length . calcFunc-vlen
)
2015 ( member . calcFunc-in
)
2016 ( crossprod . calcFunc-cross
)
2017 ( inverse . calcFunc-inv
)
2018 ( trace . calcFunc-tr
)
2019 ( transpose . calcFunc-trn
)
2020 ( vectdim . calcFunc-vlen
)
2023 (put 'maple
'math-special-function-table
2024 '((intv . math-compose-maple-intv
)))
2026 (put 'maple
'math-variable-table
2030 ( infinity . var-inf
)
2031 ( infinity . var-uinf
)
2032 ( infinity . var-nan
)
2035 (put 'maple
'math-complex-format
'I
)
2037 (put 'maple
'math-matrix-formatter
2042 math-comp-left-bracket
2043 (math-compose-vector (cdr a
)
2044 (concat math-comp-comma
" ")
2045 math-comp-vector-prec
)
2046 math-comp-right-bracket
2049 (put 'maple
'math-compose-subscr
2052 (let ((args (cdr (cdr a
))))
2054 (math-compose-expr (nth 1 a
) 1000)
2056 (math-compose-vector args
", " 0)
2059 (add-to-list 'calc-lang-allow-underscores
'maple
)
2060 (add-to-list 'calc-lang-brackets-are-subscripts
'maple
)
2062 (defun math-compose-maple-intv (a)
2064 (math-compose-expr (nth 2 a
) 0)
2066 (math-compose-expr (nth 3 a
) 0)))
2068 (defun math-read-maple-dots (x op
)
2069 (list 'intv
3 x
(math-read-expr-level (nth 3 op
))))
2072 ;; The variable math-read-big-lines is local to math-read-big-expr in
2073 ;; calc-ext.el, but is used by math-read-big-rec, math-read-big-char,
2074 ;; math-read-big-emptyp, math-read-big-error and math-read-big-balance,
2075 ;; which are called (directly and indirectly) by math-read-big-expr.
2076 ;; It is also local to math-read-big-bigp in calc-ext.el, which calls
2077 ;; math-read-big-balance.
2078 (defvar math-read-big-lines
)
2080 ;; The variables math-read-big-baseline and math-read-big-h2 are
2081 ;; local to math-read-big-expr in calc-ext.el, but used by
2082 ;; math-read-big-rec.
2083 (defvar math-read-big-baseline
)
2084 (defvar math-read-big-h2
)
2086 ;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2
2087 ;; are local to math-read-big-rec, but are used by math-read-big-char,
2088 ;; math-read-big-emptyp and math-read-big-balance which are called by
2089 ;; math-read-big-rec.
2090 ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el,
2091 ;; which calls math-read-big-balance.
2097 (defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2
2098 &optional baseline prec short
)
2099 (or prec
(setq prec
0))
2101 ;; Clip whitespace above or below.
2102 (while (and (< math-rb-v1 math-rb-v2
)
2103 (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2
(1+ math-rb-v1
)))
2104 (setq math-rb-v1
(1+ math-rb-v1
)))
2105 (while (and (< math-rb-v1 math-rb-v2
)
2106 (math-read-big-emptyp math-rb-h1
(1- math-rb-v2
) math-rb-h2 math-rb-v2
))
2107 (setq math-rb-v2
(1- math-rb-v2
)))
2109 ;; If formula is a single line high, normal parser can handle it.
2110 (if (<= math-rb-v2
(1+ math-rb-v1
))
2111 (if (or (<= math-rb-v2 math-rb-v1
)
2112 (> math-rb-h1
(length (setq math-rb-v2
2113 (nth math-rb-v1 math-read-big-lines
)))))
2114 (math-read-big-error math-rb-h1 math-rb-v1
)
2115 (setq math-read-big-baseline math-rb-v1
2116 math-read-big-h2 math-rb-h2
2117 math-rb-v2
(nth math-rb-v1 math-read-big-lines
)
2118 math-rb-h2
(math-read-expr
2119 (substring math-rb-v2 math-rb-h1
2120 (min math-rb-h2
(length math-rb-v2
)))))
2121 (if (eq (car-safe math-rb-h2
) 'error
)
2122 (math-read-big-error (+ math-rb-h1
(nth 1 math-rb-h2
))
2123 math-rb-v1
(nth 2 math-rb-h2
))
2126 ;; Clip whitespace at left or right.
2127 (while (and (< math-rb-h1 math-rb-h2
)
2128 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) math-rb-v2
))
2129 (setq math-rb-h1
(1+ math-rb-h1
)))
2130 (while (and (< math-rb-h1 math-rb-h2
)
2131 (math-read-big-emptyp (1- math-rb-h2
) math-rb-v1 math-rb-h2 math-rb-v2
))
2132 (setq math-rb-h2
(1- math-rb-h2
)))
2134 ;; Scan to find widest left-justified "----" in the region.
2137 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines
))
2141 other-char line len h
)
2142 (while (< v math-rb-v2
)
2144 len
(min math-rb-h2
(length line
)))
2145 (and (< math-rb-h1 len
)
2146 (/= (aref line math-rb-h1
) ?\
)
2147 (if (and (= (aref line math-rb-h1
) ?\-
)
2148 ;; Make sure it's not a minus sign.
2149 (or (and (< (1+ math-rb-h1
) len
)
2150 (= (aref line
(1+ math-rb-h1
)) ?\-
))
2151 (/= (math-read-big-char math-rb-h1
(1- v
)) ?\
)
2152 (/= (math-read-big-char math-rb-h1
(1+ v
)) ?\
)))
2155 (while (and (< (setq h
(1+ h
)) len
)
2156 (= (aref line h
) ?\-
)))
2160 (or other-v
(setq other-v v other-char
(aref line math-rb-h1
)))))
2164 (cond ((not (setq v other-v
))
2165 (math-read-big-error math-rb-h1 math-rb-v1
)) ; Should never happen!
2171 (let ((num (math-read-big-rec math-rb-h1 math-rb-v1 h v
))
2172 (den (math-read-big-rec math-rb-h1
(1+ v
) h math-rb-v2
)))
2173 (setq p
(if (and (math-integerp num
) (math-integerp den
))
2174 (math-make-frac num den
)
2175 (list '/ num den
)))))
2177 ;; Big radical sign.
2179 (or (= (math-read-big-char (1+ math-rb-h1
) v
) ?\|
)
2180 (math-read-big-error (1+ math-rb-h1
) v
"Malformed root sign"))
2181 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2182 (while (= (math-read-big-char (1+ math-rb-h1
) (setq v
(1- v
))) ?\|
))
2183 (or (= (math-read-big-char (setq h
(+ math-rb-h1
2)) v
) ?\_
)
2184 (math-read-big-error h v
"Malformed root sign"))
2185 (while (= (math-read-big-char (setq h
(1+ h
)) v
) ?\_
))
2186 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2187 (math-read-big-emptyp math-rb-h1
(1+ other-v
) h math-rb-v2 nil t
)
2188 (setq p
(list 'calcFunc-sqrt
(math-read-big-rec
2189 (+ math-rb-h1
2) (1+ v
)
2190 h
(1+ other-v
) baseline
))
2191 v math-read-big-baseline
))
2193 ;; Small radical sign.
2194 ((and (= other-char ?V
)
2195 (= (math-read-big-char (1+ math-rb-h1
) (1- v
)) ?\_
))
2196 (setq h
(1+ math-rb-h1
))
2197 (math-read-big-emptyp math-rb-h1 math-rb-v1 h
(1- v
) nil t
)
2198 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
2199 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2200 (while (= (math-read-big-char (setq h
(1+ h
)) (1- v
)) ?\_
))
2201 (setq p
(list 'calcFunc-sqrt
(math-read-big-rec
2202 (1+ math-rb-h1
) v h
(1+ v
) t
))
2203 v math-read-big-baseline
))
2205 ;; Binomial coefficient.
2206 ((and (= other-char ?\
()
2207 (= (math-read-big-char (1+ math-rb-h1
) v
) ?\
)
2208 (= (string-match "( *)" (nth v math-read-big-lines
)
2209 math-rb-h1
) math-rb-h1
))
2210 (setq h
(match-end 0))
2211 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2212 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
2213 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
2214 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
2215 (setq p
(list 'calcFunc-choose
2216 (math-read-big-rec (1+ math-rb-h1
) math-rb-v1
(1- h
) v
)
2217 (math-read-big-rec (1+ math-rb-h1
) (1+ v
)
2218 (1- h
) math-rb-v2
))))
2222 (setq p
(list 'neg
(math-read-big-rec (1+ math-rb-h1
) math-rb-v1
2223 math-rb-h2 math-rb-v2 v
250 t
))
2224 v math-read-big-baseline
2225 h math-read-big-h2
))
2229 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2230 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
2231 (setq h
(math-read-big-balance (1+ math-rb-h1
) v
"(" t
))
2232 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
2233 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
2234 (let ((sep (math-read-big-char (1- h
) v
))
2239 (math-read-big-error (1- h
) v
"Expected `)'"))
2241 (setq p
(math-read-big-rec
2242 (1+ math-rb-h1
) math-rb-v1
(1- h
) math-rb-v2 v
))
2243 (setq hmid
(math-read-big-balance h v
"(")
2245 (math-read-big-rec h math-rb-v1
(1- hmid
) math-rb-v2 v
))
2248 (setq p
(cons 'intv
(cons (if (= (math-read-big-char
2253 ((= (math-read-big-char (1- h
) v
) ?\
])
2254 (math-read-big-error (1- h
) v
"Expected `)'"))
2256 (or (and (math-realp (car p
)) (math-realp (nth 1 p
)))
2257 (math-read-big-error
2258 math-rb-h1 v
"Complex components must be real"))
2259 (setq p
(cons 'cplx p
)))
2261 (or (and (math-realp (car p
)) (math-anglep (nth 1 p
)))
2262 (math-read-big-error
2263 math-rb-h1 v
"Complex components must be real"))
2264 (setq p
(cons 'polar p
)))))))
2267 ((and (= other-char ?\
[)
2268 (or (= (math-read-big-char (setq h math-rb-h1
) (1+ v
)) ?\
[)
2269 (= (math-read-big-char (setq h
(1+ h
)) v
) ?\
[)
2270 (and (= (math-read-big-char h v
) ?\
)
2271 (= (math-read-big-char (setq h
(1+ h
)) v
) ?\
[)))
2272 (= (math-read-big-char h
(1+ v
)) ?\
[))
2273 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
2279 (setq h
(math-read-big-balance (1+ hleft
) v
"["))
2282 (math-read-big-error hright v
"Expected `]'"))
2284 (setq p
(cons (math-read-big-rec
2285 hleft v h
(1+ v
)) p
))
2286 (and (memq (math-read-big-char h v
) '(?\ ?\
,))
2287 (= (math-read-big-char hleft
(1+ v
)) ?\
[)))
2289 (or (= hleft math-rb-h1
)
2291 (if (= (math-read-big-char h v
) ?\
)
2293 (and (= (math-read-big-char h v
) ?\
])
2295 (math-read-big-error (1- h
) v
"Expected `]'"))
2296 (if (= (math-read-big-char h vtop
) ?\
,)
2298 (math-read-big-emptyp math-rb-h1
(1+ v
) (1- h
) math-rb-v2 nil t
)
2299 (setq v
(+ vtop
(/ (- v vtop
) 2))
2300 p
(cons 'vec
(nreverse p
)))))
2304 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
2305 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
2309 (setq widest
(math-read-big-balance h v
"[" t
))
2310 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
2311 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
2312 (setq p
(cons (math-read-big-rec
2313 h math-rb-v1
(1- widest
) math-rb-v2 v
) p
)
2315 (= (math-read-big-char (1- h
) v
) ?\
,)))
2316 (setq widest
(math-read-big-char (1- h
) v
))
2317 (if (or (memq widest
'(?\
; ?\)))
2318 (and (eq widest ?\.
) (cdr p
)))
2319 (math-read-big-error (1- h
) v
"Expected `]'"))
2322 widest
(math-read-big-balance h v
"[")
2323 p
(nconc p
(list (math-read-big-rec
2324 h math-rb-v1
(1- widest
) math-rb-v2 v
)))
2326 p
(cons 'intv
(cons (if (= (math-read-big-char (1- h
) v
)
2330 (setq p
(cons 'vec
(nreverse p
)))))
2334 (setq line
(nth v math-read-big-lines
))
2335 (string-match ">" line math-rb-h1
)
2336 (setq h
(match-end 0))
2337 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
2338 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
2339 (setq p
(math-read-big-rec math-rb-h1 v h
(1+ v
) v
)))
2341 ;; Variable name or function call.
2342 ((or (and (>= other-char ?a
) (<= other-char ?z
))
2343 (and (>= other-char ?A
) (<= other-char ?Z
))
2344 (and (>= other-char ?α
) (<= other-char ?ω
))
2345 (and (>= other-char ?Α
) (<= other-char ?Ω
)))
2346 (setq line
(nth v math-read-big-lines
))
2347 (string-match "\\([a-zA-Zα-ωΑ-Ω'_]+\\) *" line math-rb-h1
)
2348 (setq h
(match-end 1)
2349 widest
(match-end 0)
2350 p
(math-match-substring line
1))
2351 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
2352 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
2353 (if (= (math-read-big-char widest v
) ?\
()
2355 (setq line
(if (string-match "-" p
)
2357 (intern (concat "calcFunc-" p
)))
2360 (math-read-big-emptyp widest math-rb-v1 h v nil t
)
2361 (math-read-big-emptyp widest
(1+ v
) h math-rb-v2 nil t
)
2363 (setq widest
(math-read-big-balance h v
"(" t
))
2364 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
2365 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
2366 (setq p
(cons (math-read-big-rec
2367 h math-rb-v1
(1- widest
) math-rb-v2 v
) p
)
2369 (= (math-read-big-char (1- h
) v
) ?\
,)))
2370 (or (= (math-read-big-char (1- h
) v
) ?\
))
2371 (math-read-big-error (1- h
) v
"Expected `)'"))
2372 (setq p
(cons line
(nreverse p
))))
2374 (intern (math-remove-dashes p
))
2375 (if (string-match "-" p
)
2377 (intern (concat "var-" p
)))))))
2381 (setq line
(nth v math-read-big-lines
))
2382 (or (= (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\([0-9]+\\(#\\|\\^\\^\\)[0-9a-zA-Z:]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" line math-rb-h1
) math-rb-h1
)
2383 (math-read-big-error h v
"Expected a number"))
2384 (setq h
(match-end 0)
2385 p
(math-read-number (math-match-substring line
0)))
2386 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
2387 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)))
2389 ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2;
2393 (math-read-big-error math-rb-h1 v
"Inconsistent baseline in formula"))
2396 ;; Look for superscripts or subscripts.
2397 (setq line
(nth baseline math-read-big-lines
)
2398 len
(min math-rb-h2
(length line
))
2400 (while (and (< widest len
)
2401 (= (aref line widest
) ?\
))
2402 (setq widest
(1+ widest
)))
2403 (and (>= widest len
) (setq widest math-rb-h2
))
2404 (if (math-read-big-emptyp h v widest math-rb-v2
)
2405 (if (math-read-big-emptyp h math-rb-v1 widest v
)
2407 (setq p
(list '^ p
(math-read-big-rec h math-rb-v1 widest v
))
2409 (if (math-read-big-emptyp h math-rb-v1 widest v
)
2410 (setq p
(list 'calcFunc-subscr p
2411 (math-read-big-rec h v widest math-rb-v2
))
2414 ;; Look for an operator name and grab additional terms.
2415 (while (and (< h len
)
2416 (if (setq widest
(and (math-read-big-emptyp
2417 h math-rb-v1
(1+ h
) v
)
2418 (math-read-big-emptyp
2419 h
(1+ v
) (1+ h
) math-rb-v2
)
2420 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h
)
2421 (assoc (math-match-substring line
0)
2422 (math-standard-ops))))
2423 (and (>= (nth 2 widest
) prec
)
2424 (setq h
(match-end 0)))
2425 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h
)
2427 (setq widest
'("2x" * 196 195)))))
2428 (cond ((eq (nth 3 widest
) -
1)
2429 (setq p
(list (nth 1 widest
) p
)))
2430 ((equal (car widest
) "?")
2431 (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2
2432 math-rb-v2 baseline nil t
)))
2433 (or (= (math-read-big-char math-read-big-h2 baseline
) ?\
:)
2434 (math-read-big-error math-read-big-h2 baseline
2436 (setq p
(list (nth 1 widest
) p y
2438 (1+ math-read-big-h2
) math-rb-v1 math-rb-h2 math-rb-v2
2439 baseline
(nth 3 widest
) t
))
2440 h math-read-big-h2
)))
2442 (setq p
(list (nth 1 widest
) p
2443 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2
2444 baseline
(nth 3 widest
) t
))
2445 h math-read-big-h2
))))
2447 ;; Return all relevant information to caller.
2448 (setq math-read-big-baseline baseline
2450 (or short
(= math-read-big-h2 math-rb-h2
)
2451 (math-read-big-error h baseline
))
2454 (defun math-read-big-char (h v
)
2455 (or (and (>= h math-rb-h1
)
2459 (let ((line (nth v math-read-big-lines
)))
2465 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2
&optional what error
)
2466 (and (< ev1 math-rb-v1
) (setq ev1 math-rb-v1
))
2467 (and (< eh1 math-rb-h1
) (setq eh1 math-rb-h1
))
2468 (and (> ev2 math-rb-v2
) (setq ev2 math-rb-v2
))
2469 (and (> eh2 math-rb-h2
) (setq eh2 math-rb-h2
))
2470 (or what
(setq what ?\
))
2471 (let ((p (nthcdr ev1 math-read-big-lines
))
2473 (while (and (< ev1 ev2
)
2475 (setq h
(min eh2
(length (car p
))))
2476 (while (and (>= (setq h
(1- h
)) eh1
)
2477 (= (aref (car p
) h
) what
)))
2478 (and error
(>= h eh1
)
2479 (math-read-big-error h ev1
(if (stringp error
)
2481 "Whitespace expected")))
2487 ;; math-read-big-err-msg is local to math-read-big-expr in calc-ext.el,
2488 ;; but is used by math-read-big-error which is called (indirectly) by
2489 ;; math-read-big-expr.
2490 (defvar math-read-big-err-msg
)
2492 (defun math-read-big-error (h v
&optional msg
)
2494 (p math-read-big-lines
))
2496 (setq pos
(+ pos
1 (length (car p
)))
2499 (setq h
(+ pos
(min h
(length (car p
))))
2500 math-read-big-err-msg
(list 'error h
(or msg
"Syntax error")))
2501 (throw 'syntax nil
)))
2503 (defun math-read-big-balance (h v what
&optional commas
)
2504 (let* ((line (nth v math-read-big-lines
))
2505 (len (min math-rb-h2
(length line
)))
2510 (math-read-big-error nil v
(format-message
2511 "Unmatched `%s'" what
))
2513 (if (memq (aref line h
) '(?\
( ?\
[))
2514 (setq count
(1+ count
))
2515 (if (if (and commas
(= count
1))
2516 (or (memq (aref line h
) '(?\
) ?\
] ?\
, ?\
;))
2517 (and (eq (aref line h
) ?\.
)
2519 (eq (aref line
(1+ h
)) ?\.
)))
2520 (memq (aref line h
) '(?\
) ?\
])))
2521 (setq count
(1- count
))))
2525 (provide 'calc-lang
)
2527 ;;; calc-lang.el ends here