Skip to main content

Formulas for lists

When you have a list, you can apply some formulas that are specific to working with lists. Here are some:

abs

Can calculate all the absolute numbers of the numbers contained in a list:

len

You can know the number of elements a list has by using the len operator:

cat

Also, you can join two lists (as long as they have the same type) by using the cat formula:

(cat is an abbreviation of concatenate).

You can also use this formula to push an element to the end of a list, resulting in a new list:

In Decipad, every operation returns a new value. Here, cat returns a new list and leaves the arguments untouched.

Or add an element to the beginning of a list:

first

If you have a list and want to extract the first element, you can use the first formula:

last

Conversely, if you want to extract the last element of a list, you can use the last formula:

total

You can reduce a list to the sum of all the elements in it:

sort

You can generate a new list that contains all the elements in the source list sorted:

unique

You can generate a new list that contains all the unique elements in the source list sorted:

reverse

You can generate a new list that contains all the elements in the source list in reverse order:

Transpose

Transpose a list:

grow

This function compounds an initial value by a specific rate over any sequence or list of values.

stepgrowth

If you have a list of numbers, like a profit per month, you might want a list that shows how each item compares to the previous one: