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:

Mode_identity

Function: mode_identity (<arg_1>, <arg_2>) A special form used with mode_declare and macros to declare, e.g., a list of lists of flonums, or other compound data object. The first argument to mode_identity is a primitive value mode name as given to mode_declare (i.e., one of float, fixnum, number, list, or any), and the second argument is an expression which is evaluated and returned as the value of mode_identity. However, if the return value is not allowed by the mode declared in the first argument, an error or warning is signalled. The important thing is that the mode of the expression as determined by the Maxima to Lisp translator, will be that given as the first argument, independent of anything that goes on in the second argument. E.g., x: 3.3; mode_identity (fixnum, x); yields an error. mode_identity (flonum, x) returns 3.3 . This has a number of uses, e.g., if you knew that first (l) returned a number then you might write mode_identity (number, first (l)). However, a more efficient way to do it would be to define a new primitive,

firstnumb (x) ::= buildq ([x], mode_identity (number, x));

and use firstnumb every time you take the first of a list of numbers.

(%o1)                                true
(%i2) 

Related Examples

identity-kill-matrix-transpose

kill(v1,v2,v2);

v1:[-1,0,1];

v2:[0,1,-1];

Calculate