From: Jay Belanger Date: Fri, 28 Oct 2005 03:52:38 +0000 (+0000) Subject: (calcFunc-writeoutpower, math-write-out-power, calc-writeoutpower): X-Git-Tag: emacs-pretest-22.0.90~6257 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=93e7f889422e0d4475cd0ef248470e4125067f32;p=emacs.git (calcFunc-writeoutpower, math-write-out-power, calc-writeoutpower): New functions. --- diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el index ada18830988..11d550bb5d2 100644 --- a/lisp/calc/calc-alg.el +++ b/lisp/calc/calc-alg.el @@ -91,6 +91,32 @@ (calc-top-n 1)) (and n (list (prefix-numeric-value n))))))) +;;; Write out powers (a*b*...)^n as a*b*...*a*b*... +(defun calcFunc-writeoutpower (expr) + (math-normalize (math-map-tree 'math-write-out-power expr))) + +(defun math-write-out-power (expr) + (if (eq (car-safe expr) '^) + (let ((a (nth 1 expr)) + (n (nth 2 expr)) + (prod (nth 1 expr)) + (i 1)) + (if (and (integerp n) + (> n 0)) + (progn + (while (< i n) + (setq prod (math-mul prod a)) + (setq i (1+ i))) + prod) + expr)) + expr)) + +(defun calc-writeoutpower () + (interactive) + (calc-slow-wrapper + (calc-enter-result 1 "expp" + (calcFunc-writeoutpower (calc-top-n 1))))) + (defun calc-collect (&optional var) (interactive "sCollect terms involving: ") (calc-slow-wrapper