# Example NumVector defmethod 019

#### Description

This example uses the added method IncAll to respond to the message IncAll which will increment each value in a Number Vector.

#### Details

Define a method Increment which maps the function add1 to increment all values in the vector.

 (defmethod IntVector: IncAll (s) (map add1 s)) Returns: #

Define a Vector that contains some float values.

 (define V #(num| 11.433 -2.6 )) Returns: #

Send the message IncAll to increment all the values in the Vector by 1.

 (setq Y (send IncAll: V)) Returns: #

Displays the new Vector with the incremented values.

 (display #) Returns: #(num| 12.433 -1.6 )

The method can be invoked simply by name:

 (setq Y (IncAll: V)) Returns: #

Notes and Hints

To view the entry in the methods Dictionary created by the defmethod function, you can use the method name to access the directory entry by

#<Dictionary 123456>[methodName:] or

To determine the number of assigned methods:

(length (methodsOf NumVector : ))

To access the nth method name:

(methodsOf NumVector : )[n 0]

#### Related Examples

Here are examples of the defmethod function at work.

 BitVector defmethod 020 Boolean defmethod 012 Character defmethod 013 Date defmethod 015 FltVector defmethod 017 Function defmethod 016 IntVector defmethod 018 List defmethod 022 NumVector defmethod 019 Number defmethod 014 ObjectRepository defmethod 023 Pair defmethod 021 ShortVector defmethod 019 Structure defmethod 004 Structure defmethod 005 Vector defmethod 008 Void defmethod 011

Here is the link to the current function used in this example.

defmethod

Here are a number of links to other related functions.

#### Argument Types

Here are the links to the data types of the arguments used in this example.

 NumVector Symbol Dictionary

Here are a number of links to examples having similar argument types.