Generate Procedure - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


CodeTools[ProgramAnalysis]

  

GenerateProcedure

  

generate a Maple procedure from a ForLoop or WhileLoop

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

GenerateProcedure(loop)

Parameters

loop

-

WhileLoop or ForLoop data structure

Description

• 

The WhileLoops or ForLoops generated by CreateLoop can be transformed back into a Maple procedure using GenerateProcedure.

• 

The returned procedure may not be the same as the original procedure processed using CreateLoop.  Statements that do not affect the loop variables are removed and the loops are put into a canonical form.

Examples

withCodeToolsProgramAnalysis:

Form a procedure:

p := proc (A, n)
    local i;
    for i from 1 to n do
       A[i] := A[+1]^2:
    end do:
end proc;

pprocA,nlocali;foritondoA[i]A[1]^2end doend proc

(1)

Create the related ForLoop data structure:

loopCreateLoopp

loopRecordForLoop,body=,Ai=A12,layers=i,1,1,n,initialization=,variables=i,parameters=n,arrays=A

(2)

Translate the ForLoop loop back into a procedure:

GenerateProcedureloop

procA,nlocali;foritondoA[i]A[1]^2end do;returnend proc

(3)

Compatibility

• 

The CodeTools[ProgramAnalysis][GenerateProcedure] command was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.