# Special Operations for Computation Rules

### General

This article discusses several operations available in LoanPro that can be used with  Computation Rules. These rules allow you to get whole numbers out of text, grab portions of text, and work with special LoanPro variables.

#### Text to a Whole Number

The LoanPro Computation Rules allow you to extract a whole number from a piece of text using the “u/parse-int” operator. Text is often enclosed in double quotes, and dates are automatically converted to text when needed. Below is the expression to extract 80 from the string “80”.

(u/parse-int “80”)

Please note that this operator only works with whole numbers; any decimal places are lost. The following will evaluate to 2.

(u/parse-int “2.984938”)

Additionally, it will try to find the first whole number it can, even if the text isn’t a valid number. The following will return 25.

(u/parse-int “NotANumber25-534982”)

This means that if you use this operation on a date, you will only get back the year. The following only returns 2010.

(u/parse-int “2010-08-09”)

#### Text to a Number

To convert text string values in rules to numbers, we use the Double/valueOf() function. In the following example, a value from a custom field will be divided by 2.

(/ (Double/valueOf(-> setup-custom-fields (get :1) :value )) 2)

#### Substring

The Substring operator (subs) evaluates to a smaller portion of the text operand. The substring operator takes two to three operands: The text to use as a base, the starting character (the first character is 0, the second is 1, and so forth), and the ending character (if not provided then it will include everything to the right of the starting character).

Please note that the ending character is exclusive, in other words the result will not include the end character.

Below is an example that returns “Te”.

(subs “Test” 0 2)

Below is an example that outputs “LoanPro”

(subs “I love LoanPro” 6)

If the subs operator is combined with the u/parse-int operator, you can use it to get the month and day from a date.

The following will return the month of the date as a number:

(u/parse-int (subs “2010-12-23” 4 7))

The following will return the day of the month as a number

(u/parse-int (subs “2010-12-23” 8))

#### Maximum

The Maximum operator (max) will return the largest operand that it is given. It can take any number of operands. The following example returns 221:

(max 35 192 32 -999 221 100 102 202)

#### Minimum

The Minimum operator (min) will return the smallest operand that it is given. It can take any number of operands. The following example returns -999:

(max 35 192 32 -999 221 100 102 202)

#### Is Negative

The is negative operator (neg?) evaluates to true if the operand is negative. It only takes one operand which must be a number. Below returns true.

(neg? -4)

#### Is Positive

The is positive operator (pos?) evaluates to true if the operand is positive. It only takes one operand which must be a number. Below returns true.

(pos? 4)