GLaDOS Built-in Functions
Native functions implemented in Haskell
IO
printAny -> Void
Print a value to stdout with newline
putStrString -> Void
Write string without newline
putStrLnString -> Void
Write string with newline
putCharChar -> Void
Write single character
inputVoid -> String
Read line from stdin
readFileString -> String
Read entire file contents
writeFile(String, String) -> Void
Write string to file (overwrites)
appendFile(String, String) -> Void
Append string to file
fileExistsString -> Bool
Check if file exists
Conversions
showAny -> String
Convert to string representation
toIntAny -> Int
Convert to Int
toFloatAny -> Float
Convert to Float
toStringAny -> String
Convert to String
toBoolAny -> Bool
Convert to Bool (truthy check)
toCharInt|String -> Char
Convert to Char
toListAny -> List
Convert to List
ordChar -> Int
Get ASCII/Unicode code point
chrInt -> Char
Get character from code point
typeofAny -> String
Get type name of value
Strings
split(String, String) -> List
Split string by delimiter
join(List, String) -> String
Join list with separator
trimString -> String
Remove leading/trailing whitespace
upperString -> String
Convert to uppercase
lowerString -> String
Convert to lowercase
replace(String, String, String) -> String
Replace all occurrences
contains(String|List, Any) -> Bool
Check if contains element
startsWith(String, String) -> Bool
Check prefix
endsWith(String, String) -> Bool
Check suffix
substring(String, Int, Int) -> String
Extract substring (start, len)
format(String, List) -> String
Format string with placeholders {}
charsString -> List
Convert string to list of chars
linesString -> List
Split string by newlines
wordsString -> List
Split string by whitespace
reverseList|String -> List|String
Reverse a list or string
Lists
lenList|Map|String -> Int
Get length of collection
get(List|Map, Index) -> Value
Get value by index/key
set(List, Int, Value) -> List
Set value at index
push(List, Value) -> List
Append value to list
popList -> List
Remove last element
headList -> Value
Get first element
tailList -> List
Get all except first
initList -> List
Get all except last
lastList -> Value
Get last element
concat(List, List) -> List
Concatenate two lists
sortList -> List
Sort list (numbers or strings)
range(Int, Int) -> List
Generate range [start, end)
zip(List, List) -> List
Zip two lists into pairs
take(List, Int) -> List
Take first n elements
drop(List, Int) -> List
Drop first n elements
slice(List, Int, Int) -> List
Get slice [start, end)
indexOf(List|String, Value) -> Int
Find index of element (-1 if not found)
remove(List, Int) -> List
Remove element at index
insert(List, Int, Value) -> List
Insert value at index
uniqueList -> List
Remove duplicates
flattenList -> List
Flatten nested lists
sumList -> Int|Float
Sum of numeric list
productList -> Int|Float
Product of numeric list
minimumList -> Value
Minimum value in list
maximumList -> Value
Maximum value in list
isEmptyList|String|Map -> Bool
Check if collection is empty
Math
absNum -> Num
Absolute value
min(Num, Num) -> Num
Minimum of two values
max(Num, Num) -> Num
Maximum of two values
pow(Num, Num) -> Num
Power (base^exp)
sqrtNum -> Float
Square root
floorFloat -> Int
Floor (round down)
ceilFloat -> Int
Ceiling (round up)
roundFloat -> Int
Round to nearest integer
sinNum -> Float
Sine (radians)
cosNum -> Float
Cosine (radians)
tanNum -> Float
Tangent (radians)
logNum -> Float
Natural logarithm
expNum -> Float
e^x
randomVoid -> Float
Random float [0, 1)
randomInt(Int, Int) -> Int
Random int in range [min, max]
piVoid -> Float
Pi constant
eulerVoid -> Float
Euler's number (e)
System
envString -> String
Get environment variable
sleepInt -> Void
Sleep for milliseconds
timeVoid -> Int
Current Unix timestamp (seconds)
shellString -> List
Execute shell command
assert(Bool, String) -> Void
Assert or panic
panicString -> Void
Terminate with error
debugAny -> Any
Print and return value
getArgsVoid -> List
Get command line arguments