GLaDOS Built-in Functions

Native functions implemented in Haskell

← Back to IDE

IO

print
Any -> Void
Print a value to stdout with newline
putStr
String -> Void
Write string without newline
putStrLn
String -> Void
Write string with newline
putChar
Char -> Void
Write single character
input
Void -> String
Read line from stdin
readFile
String -> String
Read entire file contents
writeFile
(String, String) -> Void
Write string to file (overwrites)
appendFile
(String, String) -> Void
Append string to file
fileExists
String -> Bool
Check if file exists

Conversions

show
Any -> String
Convert to string representation
toInt
Any -> Int
Convert to Int
toFloat
Any -> Float
Convert to Float
toString
Any -> String
Convert to String
toBool
Any -> Bool
Convert to Bool (truthy check)
toChar
Int|String -> Char
Convert to Char
toList
Any -> List
Convert to List
ord
Char -> Int
Get ASCII/Unicode code point
chr
Int -> Char
Get character from code point
typeof
Any -> String
Get type name of value

Strings

split
(String, String) -> List
Split string by delimiter
join
(List, String) -> String
Join list with separator
trim
String -> String
Remove leading/trailing whitespace
upper
String -> String
Convert to uppercase
lower
String -> 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 {}
chars
String -> List
Convert string to list of chars
lines
String -> List
Split string by newlines
words
String -> List
Split string by whitespace
reverse
List|String -> List|String
Reverse a list or string

Lists

len
List|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
pop
List -> List
Remove last element
head
List -> Value
Get first element
tail
List -> List
Get all except first
init
List -> List
Get all except last
last
List -> Value
Get last element
concat
(List, List) -> List
Concatenate two lists
sort
List -> 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
unique
List -> List
Remove duplicates
flatten
List -> List
Flatten nested lists
sum
List -> Int|Float
Sum of numeric list
product
List -> Int|Float
Product of numeric list
minimum
List -> Value
Minimum value in list
maximum
List -> Value
Maximum value in list
isEmpty
List|String|Map -> Bool
Check if collection is empty

Math

abs
Num -> 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)
sqrt
Num -> Float
Square root
floor
Float -> Int
Floor (round down)
ceil
Float -> Int
Ceiling (round up)
round
Float -> Int
Round to nearest integer
sin
Num -> Float
Sine (radians)
cos
Num -> Float
Cosine (radians)
tan
Num -> Float
Tangent (radians)
log
Num -> Float
Natural logarithm
exp
Num -> Float
e^x
random
Void -> Float
Random float [0, 1)
randomInt
(Int, Int) -> Int
Random int in range [min, max]
pi
Void -> Float
Pi constant
euler
Void -> Float
Euler's number (e)

System

env
String -> String
Get environment variable
sleep
Int -> Void
Sleep for milliseconds
time
Void -> Int
Current Unix timestamp (seconds)
shell
String -> List
Execute shell command
assert
(Bool, String) -> Void
Assert or panic
panic
String -> Void
Terminate with error
debug
Any -> Any
Print and return value
getArgs
Void -> List
Get command line arguments