Complete reference for all built-in functions in Keikaku. Click on any function to see its usage.
declare(...args)Print values to standard output, space-separated
inquire(prompt)Read user input from stdin, returns string
text(value)Convert any value to its string representation
number(value)Convert string to integer
decimal(value)Convert string to float
classify(value)Get type name as string
boolean(value)Convert to boolean
measure(x)Get length of list, string, or dict
push(list, item)Append item to list (mutates)
pop(list)Remove and return last item
reverse(list)Return reversed copy of list
sort(list)Return sorted copy of list
span(n)Generate list [0, 1, ..., n-1]
span(start, end)Generate list [start, ..., end-1]
slice(list, start, end)Extract sublist
contains(list, item)Check if list contains item
index(list, item)Find index of item (-1 if not found)
keys(dict)Get list of dictionary keys
values(dict)Get list of dictionary values
uppercase(s)Convert string to uppercase
lowercase(s)Convert string to lowercase
split(s, delimiter)Split string into list
join(list, delimiter)Join list into string
trim(s)Remove leading/trailing whitespace
startswith(s, prefix)Check if string starts with prefix
endswith(s, suffix)Check if string ends with suffix
replace(s, old, new)Replace occurrences in string
substr(s, start, length)Extract substring
abs(x)Absolute value
min(a, b)Return smaller value
max(a, b)Return larger value
floor(x)Round down to integer
ceil(x)Round up to integer
round(x)Round to nearest integer
sqrt(x)Square root
power(base, exp)Exponentiation
random(min, max)Random integer in range [min, max]
sin(x)Sine (radians)
cos(x)Cosine (radians)
log(x)Natural logarithm
decipher(filepath)Read entire file as string
inscribe(filepath, content)Write string to file
append_file(filepath, content)Append to file
file_exists(filepath)Check if file exists
delete_file(filepath)Delete a file
list_dir(path)List directory contents
proceed(gen)Advance generator and get next value
transmit(gen, value)Send value into generator, get next yield
receive()Inside generator: get transmitted value
disrupt(gen, error)Throw exception into generator
sleep(ms)Pause execution for milliseconds
defer(ms, protocol, ...args)Schedule delayed execution
resolve(value)Create immediately resolved promise
timestamp()Get current Unix timestamp (seconds)
timestamp_ms()Get current Unix timestamp (milliseconds)
encode_json(value)Convert value to JSON string
decode_json(string)Parse JSON string to value
transform(list, fn)Map function over list
select(list, fn)Filter list by predicate
fold(list, fn, initial)Reduce list to single value
1# Read CSV, process, write output2content := decipher("data.csv")3lines := split(content, "\n")45results := []6cycle through lines as line:7 foresee measure(trim(line)) > 0:8 fields := split(line, ",")9 processed := uppercase(fields[0])10 push(results, processed)1112output := join(results, "\n")13inscribe("output.txt", output)14declare("Processed", measure(results), "lines")1# Transform, filter, reduce pattern2numbers := span(1, 101)34# Double all numbers5doubled := transform(numbers, protocol(x): yield x * 2)67# Keep only divisible by 108filtered := select(doubled, protocol(x): yield x % 10 == 0)910# Sum them up11total := fold(filtered, protocol(a, b): yield a + b, 0)1213declare("Sum of even multiples of 10:", total)