keithlisp/doc/stdlib_arithmetic.md

42 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2021-09-23 13:51:39 +00:00
# Arithmetic
## `+`
```
(+ &rest numbers)
```
`+` returns the sum of its arguments, skipping any inputs that are not
ints or floats. If no arguments are given, it returns 0.
## `-`
```
(- number)
(- number &rest more-numbers)
```
If called with one argument, `-` returns the negation of that argument.
If called with more than one argument, `-` subtracts `more-numbers` from
`number`, skipping any inputs that are not ints or floats.
If `number` is not an int or float, `-` returns nil.
## `*`
```
(* &rest numbers)
```
`*` returns the product of its arguments, skipping any inputs that are
not ints or floats. If no arguments are given, it returns 1.
## `/`
```
(/ number &rest more-numbers)
```
`/` divides `number` by `more-numbers`, skipping any inputs that are not
ints or floats. It always returns a float.
If `number` is not an int or float, `/` returns nil.
## `int/`
```
(int/ number &rest more-numbers)
```
`int/` performs integer division, dividing `number` by `more-numbers`,
skipping any inputs that are not ints or floats, and returning an int.
If `number` is not an int or float, `int/`returns nil.