A user of ours came up with an interesting request: taking a procedure name as an argument and then within the procedure, return a set containing the names of all variables within the procedure. This task can be accomplished in one of two ways, one with local variables, one with global variables.

One method is:

find_vars_in_proc(f :: procedure, $)
  return {op(2, eval(f))};
end proc;

for variables that Maple unambiguously determines to be local variables. For global variables, a slight variation appears as:

find_vars_in_proc(f :: procedure, $)
  return {op(2, eval(f)), op(6, eval(f))};
end proc;

As always, typing ?procedure directly in the worksheet brings up the help guide containing more information on operands of a procedure!


Please Wait...