# 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.

Avoid Non-Clojure Languages

Avoid using interop of languages such as Java when using LoanPro's computation rules.

Do not use functions such as

• Double/valueOf
• Integer/parseInt
• Double/parseDouble

Instead, opt to use Lisp/Clojure specific functions and the operators provided by LoanPro, covered below.

#### 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")$$

Floating point number extraction is covered below.

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 Floating Point Number

The LoanPro Computation Rules also allow you to extract floating point numbers from a piece of text using the “u/parse-float” operator. The examples used in the section above apply the same here but for floating point numbers, instead of whole numbers.

Below is the expression to extract 80.5 from the string “80.5”.

$$(u/parse-int "80.5")$$

#### 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)$$