## `misc::breakmap` -- stops the mapping currently done by maprec

#### Introduction

`misc::breakmap`() stops the recursive application of a function to all subexpressions of an expression that `misc::maprec` is just working on.

#### Call(s)

`misc::breakmap()`

#### Returns

`misc::breakmap` always returns `TRUE`.

#### Related Functions

`misc::maprec`

#### Details

- `misc::breakmap` is useful as a command inside the procedure mapped by `misc::maprec` in case we know that we are finished with our work and the remaining recursive mapping is not necessary.

#### Example 1

We want to know whether a given expression contains a particular type `t`. As soon as we have found the first occurence of `t`, we can terminate our search.

    >> myfound := FALSE:
       misc::maprec(hold(((23+5.0)/3+4*I)*PI), {DOM_COMPLEX}=proc() begin \
                    myfound := misc::breakmap(); args() end_proc) :
       myfound; delete myfound :

                                       TRUE

What did we do? We told `misc::maprec` just to go down the expression tree and look for subexpressions of type `DOM_COMPLEX`; and, whenever such subexpression should be found, to apply a certain procedure to it. That procedure stops the recursive mapping, remembers that we have found the type we had searched for, and returns exactly its argument such that the result returned by `misc::maprec` equals the input. In the example below, we test whether our given expression contains the type `DOM_POLY`.

    >> myfound := FALSE:
       misc::maprec(hold(((23+5.0)/3+4*I)*PI), {DOM_POLY}=proc() begin \
                    myfound := misc::breakmap() ; args() end_proc) :
       myfound; delete myfound :

                                       FALSE

Note that you do not need to use this method when searching for subexpressions of a given type; calling `hastype` is certainly more convenient.

#### Changes

- used to be called `breakmap`

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000