Built-in functions and values available in all LOVE-LANG programmes via @Import[Prelude::*].
The Prelude is LOVE-LANG’s standard library module that is automatically available to all programmes. Import it with:
| Name | Type | Value | Description |
|---|
true | Boolean | true | Boolean truth |
false | Boolean | false | Boolean falsity |
nil | Nil | nil | The null value |
inf | Number | ∞ | Positive infinity |
product = [[ * 4 5 ]] # 20
power = [[ ** 2 8 ]] # 256
| Function | Arity | Description |
|---|
+ | n | Sum of all arguments |
- | 2 | Subtraction |
* | n | Product of all arguments |
/ | 2 | Division |
% | 2 | Modulo |
** | 2 | Exponentiation |
Math.sqrt | 1 | Square root |
Math.abs | 1 | Absolute value |
Math.max | n | Maximum value |
Math.min | n | Minimum value |
Math.floor | 1 | Floor |
Math.ceil | 1 | Ceiling |
Math.round | 1 | Round to nearest integer |
joined = [[ String.concat "Hello, " name ]]
upper = [[ String.upper "love" ]]
lower = [[ String.lower "LOVE" ]]
trimmed = [[ String.trim " love " ]]
length = [[ String.length "LOVE-LANG" ]]
csv = [[ String.join "," ["a" "b" "c"] ]]
| Function | Arity | Description |
|---|
String.concat | n | Concatenate strings |
String.upper | 1 | Uppercase |
String.lower | 1 | Lowercase |
String.trim | 1 | Trim whitespace |
String.length | 1 | String length |
String.join | 2 | Join list with separator |
String.split | 2 | Split by separator |
String.contains? | 2 | Substring check |
String.starts-with? | 2 | Prefix check |
String.ends-with? | 2 | Suffix check |
String.from-number | 1 | Convert number to string |
Number.from-string | 1 | Parse number from string |
mapped = [[ List.map double [1 2 3] ]]
filtered = [[ List.filter positive? [1 -2 3 -4] ]]
folded = [[ List.fold + 0 [1 2 3 4 5] ]]
flattened = [[ List.flatten [[1 2] [3 4]] ]]
reversed = [[ List.reverse [1 2 3] ]]
| Function | Arity | Description |
|---|
List.map | 2 | Apply function to each element |
List.filter | 2 | Keep elements matching predicate |
List.fold | 3 | Fold list with accumulator |
List.flatten | 1 | Flatten nested list |
List.reverse | 1 | Reverse list |
List.length | 1 | List length |
List.first | 1 | First element |
List.last | 1 | Last element |
List.rest | 1 | All but first |
List.take | 2 | Take N elements |
List.drop | 2 | Drop N elements |
List.contains? | 2 | Membership check |
List.unique | 1 | Remove duplicates |
List.sort | 1 | Sort ascending |
List.zip | 2 | Zip two lists |
all-true = [[ @and [true true true] ]]
any-true = [[ @or [false true false] ]]
| Function | Arity | Description |
|---|
@and | n | All truthy |
@or | n | Any truthy |
not | 1 | Boolean negation |
= | 2 | Equality |
!= | 2 | Inequality |
> | 2 | Greater than |
< | 2 | Less than |
>= | 2 | Greater than or equal |
<= | 2 | Less than or equal |
These must be declared in model.edn before use:
@println "Line with newline"
| Effector | Arity | Description |
|---|
@print | 1 | Print to stdout |
@println | 1 | Print with newline |
@read-file | 1 | Read file contents |
@write-file | 2 | Write string to file |
@http-get | 1 | HTTP GET request |
@http-post | 2 | HTTP POST request |
@sql-write | 2 | Database write |
@sql-read | 2 | Database query |