Skip to content

Standard Library — Prelude

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:

@Import[Prelude::*]

NameTypeValueDescription
trueBooleantrueBoolean truth
falseBooleanfalseBoolean falsity
nilNilnilThe null value
infNumberPositive infinity

sum = [[ + 1 2 3 ]] # 6
diff = [[ - 10 3 ]] # 7
product = [[ * 4 5 ]] # 20
ratio = [[ / 10 2 ]] # 5
mod = [[ % 10 3 ]] # 1
power = [[ ** 2 8 ]] # 256
FunctionArityDescription
+nSum of all arguments
-2Subtraction
*nProduct of all arguments
/2Division
%2Modulo
**2Exponentiation
Math.sqrt1Square root
Math.abs1Absolute value
Math.maxnMaximum value
Math.minnMinimum value
Math.floor1Floor
Math.ceil1Ceiling
Math.round1Round 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"] ]]
FunctionArityDescription
String.concatnConcatenate strings
String.upper1Uppercase
String.lower1Lowercase
String.trim1Trim whitespace
String.length1String length
String.join2Join list with separator
String.split2Split by separator
String.contains?2Substring check
String.starts-with?2Prefix check
String.ends-with?2Suffix check
String.from-number1Convert number to string
Number.from-string1Parse 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] ]]
FunctionArityDescription
List.map2Apply function to each element
List.filter2Keep elements matching predicate
List.fold3Fold list with accumulator
List.flatten1Flatten nested list
List.reverse1Reverse list
List.length1List length
List.first1First element
List.last1Last element
List.rest1All but first
List.take2Take N elements
List.drop2Drop N elements
List.contains?2Membership check
List.unique1Remove duplicates
List.sort1Sort ascending
List.zip2Zip two lists

all-true = [[ @and [true true true] ]]
any-true = [[ @or [false true false] ]]
negated = [[ not true ]]
equal = [[ = 1 1 ]]
FunctionArityDescription
@andnAll truthy
@ornAny truthy
not1Boolean negation
=2Equality
!=2Inequality
>2Greater than
<2Less than
>=2Greater than or equal
<=2Less than or equal

These must be declared in model.edn before use:

[[[[[
@print "Hello, World!"
]]]]]
[[[[[
@println "Line with newline"
]]]]]
EffectorArityDescription
@print1Print to stdout
@println1Print with newline
@read-file1Read file contents
@write-file2Write string to file
@http-get1HTTP GET request
@http-post2HTTP POST request
@sql-write2Database write
@sql-read2Database query