 CompSeq - Maple Programming Help

CompSeq

A representation for computation sequences

 Calling Sequence CompSeq(assignments) CompSeq(locals=list1, globals=list2, params=list3, assignments)

Parameters

 list1, list2, list3 - lists of names assignments - list of the form name=expression

Description

 • The function CompSeq is a placeholder for representing a computation sequence.
 • Specification of local and global variables as well as parameters is optional.
 • The actual computation sequence is specified as a list of the form name=expression and represents an assignment of the value of the expression to the name. The last assignment in the list is also the result of the computation sequence.
 • Computation sequences can be converted to and from procedures, simplified and optimized. For more information, see codegen[optimize].

Examples

 > f:= proc(a,b) local i,j; global x,y; x:=a+b; i := a*b; j := x+i; y := a+sin(x) end proc;
 ${f}{:=}{\mathbf{proc}}\left({a}{,}{b}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{,}{j}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{global}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{,}{y}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{:=}{a}{+}{b}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{:=}{a}{*}{b}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{j}{:=}{x}{+}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{y}{:=}{a}{+}{\mathrm{sin}}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $s≔\mathrm{convert}\left(f,\mathrm{CompSeq}\right)$
 ${s}{≔}{\mathrm{CompSeq}}{}\left({\mathrm{locals}}{=}\left[{i}{,}{j}\right]{,}{\mathrm{globals}}{=}\left[{x}{,}{y}\right]{,}{\mathrm{params}}{=}\left[{a}{,}{b}\right]{,}\left[{x}{=}{a}{+}{b}{,}{i}{=}{a}{}{b}{,}{j}{=}{x}{+}{i}{,}{y}{=}{a}{+}{\mathrm{sin}}{}\left({x}\right)\right]\right)$ (2)
 > $\mathrm{simplify}\left(s\right)$
 ${\mathrm{CompSeq}}{}\left({\mathrm{globals}}{=}\left[{x}{,}{y}\right]{,}{\mathrm{params}}{=}\left[{a}{,}{b}\right]{,}\left[{x}{=}{a}{+}{b}{,}{y}{=}{a}{+}{\mathrm{sin}}{}\left({x}\right)\right]\right)$ (3)
 > $\mathrm{type}\left(s,\mathrm{CompSeq}\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{convert}\left(s,\mathrm{procedure}\right)$
 ${\mathbf{proc}}\left({a}{,}{b}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{,}{j}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{global}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{,}{y}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{:=}{a}{+}{b}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{:=}{a}{*}{b}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{j}{:=}{x}{+}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{y}{:=}{a}{+}{\mathrm{sin}}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)