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

Online Help

All Products    Maple    MapleSim


SoftwareMetrics

  

NestingMetrics

  

provide details about nesting depth

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

NestingMetrics(prc, dst, sm)

Parameters

prc

-

Maple procedure, module, or list of procedures or modules

dst

-

(optional) BooleanOpt(distinguish); specifies whether to distinguish between selection and repetition structures

sm

-

(optional) BooleanOpt(summarize); specifies whether to return the output in a tabular format or as an expression sequence containing one (or two) row Vector(s)

Description

• 

The NestingMetrics routine provides details about nesting depth of selection and repetition structures for each procedure or module contained in the parameter prc.

  

Selection structures include if statements and if operators.

  

Repetition structures include for-from and for-in statements as well as seq, $, map, add, and mul operators.

• 

The distinguish option (dst) controls how selection and repetition structures are treated with regards to nesting depth.

  

If omitted (or given as distinguish=false), no distinctions are made between selection and repetition structures, and vice-versa.

  

The condition distinguish=true can be abbreviated as distinguish.

• 

The summarize option (sm) controls how the result is returned.

  

If the summarize option is omitted (or is given as summarize=false), the result returned is an Array which tabulates the details of the nesting depths for each procedure and module contained in prc. Additionally, if prc contains at least two procedures (or a module with more than one export), the routine computes the total nesting depth for of all the procedures and modules combined. This total is included in the last row of the output Array.

  

To force the display of large Arrays, you can increase the rtablesize setting using the interface function.

  

If given as summarize=true, the result returned is a row Vector (when distinguish=false) or an expression sequence of two row Vectors (when distinguish=true). These row Vectors represent total nesting depth for all of the procedures and modules contained in prc.

  

Regardless of the value of summarize, the j-th element of the Vectors contained in the output represent the number of structures for the j-th nesting level.

  

The condition summarize=true can be abbreviated as summarize.

Examples

withSoftwareMetrics:

Example procedure taken from the Maple Programming Guide

sieve := proc(n::integer)
    local i, k, flags, count, twice_i;
    count := 0;
    for i from 2 to n do flags[i] := true end do;
    for i from 2 to n do
        if flags[i] then
            twice_i := 2*i;
            for k from twice_i by i to n do flags[k] := false end do;
            count := count+1;
        end if;
    end do;
    count;
end proc:

NestingMetricssieve

sieve211

(1)

NestingMetricssieve,distinguish

Selection StructuresRepetition Structuressieve121

(2)

NestingMetricssieve,distinguish,summarize

1,21

(3)

Examples using Maple library code

NestingMetricsdsolve,`dsolve/numeric`,distinguish=false

dsolve5131263dsolve/numeric6710369376341TOTAL7211681439341

(4)

NestingMetricsdsolve,`dsolve/numeric`,distinguish=true

Selection StructuresRepetition Structuresdsolve5119419dsolve/numeric687250913825TOTAL7383591323915

(5)

NestingMetricsCurveFitting

NestingMetricsCurveFitting,summarize

958259231012

(6)

See Also

Array

interface

ProgrammingGuide/Debugging

SoftwareMetrics

Vector