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:

Block

Function: block ([<v_1>, ..., <v_m>], <expr_1>, ..., <expr_n>)

load(functs);
block([y:""], for i in (makelist(n, n, 1, 10)) do (y:flatten(append(makelist(i/100.0, i, i, i), [""]))), return(y));

Function: block (<expr_1>, ..., <expr_n>) block evaluates <expr_1>, ..., <expr_n> in sequence and returns the value of the last expression evaluated. The sequence can be modified by the go, throw, and return functions. The last expression is <expr_n> unless return or an expression containing throw is evaluated. Some variables <v_1>, ..., <v_m> can be declared local to the block; these are distinguished from global variables of the same names. If no variables are declared local then the list may be omitted. Within the block, any variable other than <v_1>, ..., <v_m> is a global variable.

block saves the current values of the variables <v_1>, ..., <v_m> (if any) upon entry to the block, then unbinds the variables so that they evaluate to themselves. The local variables may be bound to arbitrary values within the block but when the block is exited the saved values are restored, and the values assigned within the block are lost.

The declaration local(<v_1>, ..., <v_m>) within block saves the properties associated with the symbols <v_1>, ..., <v_m>, removes any properties before evaluating other expressions, and restores any saved properties on exit from the block. Some declarations are implemented as properties of a symbol, including :=, array, dependencies, atvalue, matchdeclare, atomgrad, constant, nonscalar, assume, and some others. The effect of local is to make such declarations effective only within the block; otherwise declarations within a block are actually global declarations.

block may appear within another block. Local variables are established each time a new block is evaluated. Local variables appear to be global to any enclosed blocks. If a variable is non-local in a block, its value is the value most recently assigned by an enclosing block, if any, otherwise, it is the value of the variable in the global environment. This policy may coincide with the usual understanding of "dynamic scope".

The value of the block is the value of the last statement or the value of the argument to the function return which may be used to exit explicitly from the block. The function go may be used to transfer control to the statement of the block that is tagged with the argument to go. To tag a statement, precede it by an atomic argument as another statement in the block. For example: block ([x], x:1, loop, x: x+1, ..., go(loop), ...). The argument to go must be the name of a tag appearing within the block. One cannot use go to transfer to a tag in a block other than the one containing the go.

Blocks typically appear on the right side of a function definition but can be used in other places as well.

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

(%o1)                                true
(%i2) 

Related Examples

block-load

nod(a,b):=block(load(...

nod(34,83);

Calculate

block-if

eq(n):=block(if(1=n) ...

eq(1);

eq(2);

Calculate

block-local

foo (x) := 1 - x;

foo (100);

block (local (foo), ...

Calculate

block-equal-part-reveal-subst

answer: 4*x=3;

block([atp: reveal(an...

Calculate

block-do-if-length-makelist-random-while

merge(a) := block( lo...

combinarListas(b, izq...

mergesort(makelist(ra...

Calculate

block-part-reveal-subst

answer: 4*x+3=3;

block([atp: reveal(an...

atp: reveal(answer,1);

Calculate

block-cos-is

LONCAPALIST: [sin, 1,...

RESPONSE: [1];

block ( [], if equ...

Calculate

block-genmatrix-if-map-matrix-mod-print-quotient-transpose

f(x) := block([], if ...

n : 4;

W : matrix([0,-1,1,1]...

Calculate