Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Printf Calculator

Printf

Function: printf (<dest>, <string>)

T[n]:=1/(n+1)*binomial(2*n, n);
catalan: makelist(T[n], n, 1, 10);
plot2d([%e^x, if(x>2) then 3 else 2], [x, 0, 5], [y, 0, 5]);
B[k, n]:=binomial(k, n);
C[k, n]:=combination(k, n);
P[k, n]:=permutation(k, n);
pascal:for k:0 thru 10 do (printf(true, "~&"),    for n:0 thru 10 do (if (B[k, n] = 0) then nil else printf(true, " ~5d ~&", B[k, n])));

Function: printf (<dest>, <string>, <expr_1>, ..., <expr_n>) Makes the Common Lisp function FORMAT available in Maxima. (From gcl.info: "format produces formatted output by outputting the characters of control-string string and observing that a tilde introduces a directive. The character after the tilde, possibly preceded by prefix parameters and modifiers, specifies what kind of formatting is desired. Most directives use one or more elements of args to create their output.")

The following description and the examples may give an idea of using printf. See a Lisp reference for more information.

~% new line ~& fresh line ~t tab ~$ monetary ~d decimal integer ~b binary integer ~o octal integer ~x hexadecimal integer ~br base-b integer ~r spell an integer ~p plural ~f floating point ~e scientific notation ~g ~f or ~e, depending upon magnitude ~h bigfloat ~a uses Maxima function string ~s like ~a, but output enclosed in "double quotes" ~~ ~ ~< justification, ~> terminates ~( case conversion, ~) terminates ~[ selection, ~] terminates ~{ iteration, ~} terminates

Note that the selection directive ~[ is zero-indexed. Also note that the directive ~* is not supported.

          (%i1) printf( false, "~a ~a ~4f ~a ~@r",
                        "String",sym,bound,sqrt(12),144), bound = 1.234;
          (%o1)                 String sym 1.23 2*sqrt(3) CXLIV
          (%i2) printf( false,"~{~a ~}",["one",2,"THREE"] );
          (%o2)                          one 2 THREE
          (%i3) printf(true,"~{~{~9,1f ~}~%~}",mat ),
                    mat = args(matrix([1.1,2,3.33],[4,5,6],[7,8.88,9]))$
                1.1       2.0       3.3
                4.0       5.0       6.0
                7.0       8.9       9.0
          (%i4) control: "~:(~r~) bird~p ~[is~;are~] singing."$
          (%i5) printf( false,control, n,n,if n=1 then 0 else 1 ), n=2;
          (%o5)                    Two birds are singing.

If <dest> is a stream or true, then printf returns false. Otherwise, printf returns a string containing the output.

There are also some inexact matches for printf. Try ?? printf to see them.

(%o1)                                true
(%i2) 

Printf Example

Related Examples

printf

/* Definintion von zw...

a:[false,true,false,t...

b:[false,false,true,t...

Calculate

printf

printf(false, "~x", 1...

Calculate

printf

x: 101 + 105 * (2**32...

printf(true,"~x",123);

Calculate

printf

f(a):= a[1] + a[2]*(2...

f2(a):= f(a[1]) + f(a...

b:[[1,3408,1,1507328,...

Calculate

printf

/* Definintion von zw...

b:[false,false,true,t...

/* Definition einer V...

Calculate

printf

/* Definintion von zw...

b:[false,false,true,t...

eq2: /* Definition ei...

Calculate

printf

printf(false, "~x", 1...

Calculate

printf

printf(false, "~d", 1...

Calculate

printf

printf(false, "~x", 1...

Calculate