www.delorie.com/gnu/docs/maxima/maxima_19.html   search  
 
Buy GNU books!


Maxima Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Introduction to Expressions

There are a number of reserved words which cannot be used as variable names. Their use would cause a possibly cryptic syntax error.

 
INTEGRATE            NEXT           FROM                 DIFF            
IN                   AT             LIMIT                SUM             
FOR                  AND            ELSEIF               THEN            
ELSE                 DO             OR                   IF              
UNLESS               PRODUCT        WHILE                THRU            
STEP                                                                     

Most things in MAXIMA are expressions. A sequence of expressions can be made into an expression by separating them by commas and putting parentheses around them. This is similar to the C comma expression.

 
(C29) x:3$
(C30) joe:(x:x+1,x:x*x);
(D30) 16
(C31) joe:(if (x >17) then 2 else 4);
(D31) 4
(C32) joe:(if (x >17) then x:2 else joe:4,joe+x);
(D32) 20

Even loops in maxima are expressions, although the value they return is the not to useful DONE

 
(C33) joe:(x:1,for i from 1 thru 10 do (x:x*i));
(D33) DONE
whereas what you really want is probably is to include a third term in the comma expression which actually gives back the value.

 
(C34) joe:(x:1,for i from 1 thru 10 do (x:x*i),x);
(D34) 3628800


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003