Native Functions

Built-in functions available in every Mac program without imports.

Time & Introspection

FunctionSignatureReturnsDescription
clockclock()numberWall-clock time in seconds
typetype(value)stringRuntime type name

String Operations

FunctionSignatureReturnsDescription
lenlen(str)numberString length (also works on arrays)
substrsubstr(str, start, length)stringExtract substring
splitsplit(str, delimiter)[string]Split into array
joinjoin(array, separator)stringJoin array into string
upperupper(str)stringConvert to uppercase
lowerlower(str)stringConvert to lowercase
trimtrim(str)stringRemove surrounding whitespace
replacereplace(str, from, to)stringReplace all occurrences

Math

FunctionSignatureReturnsDescription
sqrtsqrt(n)numberSquare root
absabs(n)numberAbsolute value
powpow(base, exp)numberExponentiation
floorfloor(n)numberRound down
ceilceil(n)numberRound up

Array Mutation

FunctionSignatureReturnsDescription
pushpush(array, value)nilAppend element (mutates)
poppop(array)TRemove and return last element

Array Transforms

FunctionSignatureReturnsDescription
mapmap(array, fn)[T]Transform each element
filterfilter(array, fn)[T]Keep matching elements
reducereduce(array, fn, init)TFold with accumulator
findfind(array, fn)TFirst matching element
flatMapflatMap(array, fn)[T]Map and flatten one level
flattenflatten(array)[T]Flatten one nesting level
reversereverse(array)[T]Reversed copy
sortsort(array)[T]Sorted copy
sortsort(array, cmp)[T]Sort with comparator
taketake(array, n)[T]First n elements
dropdrop(array, n)[T]Skip first n elements
zipzip(a, b)[[A, B]]Pair elements from two arrays
enumerateenumerate(array)[[number, T]]Index-value pairs
takeWhiletakeWhile(array, fn)[T]Take elements while predicate is true
dropWhiledropWhile(array, fn)[T]Drop elements while predicate is true
partitionpartition(array, fn)[[T], [T]]Split by predicate
groupBygroupBy(array, fn){string: [T]}Group by key function
uniqueunique(array)[T]Remove duplicates
chunkchunk(array, n)[[T]]Split into groups of n
scanscan(array, fn, init)[T]Reduce keeping intermediates
eacheach(array, fn)nilSide-effect iteration

Array Predicates

FunctionSignatureReturnsDescription
anyany(array, fn)boolAny element matches
allall(array, fn)boolAll elements match

Generators

FunctionSignatureReturnsDescription
rangerange(end)[number][0, 1, ..., end-1]
rangerange(start, end)[number][start, ..., end-1]
rangerange(start, end, step)[number]With custom step

Functional Utilities

FunctionSignatureReturnsDescription
partialpartial(fn, ...args)functionBind arguments to a function, returning a new function with fewer parameters

User Input

FunctionSignatureReturnsDescription
inputinput(prompt)stringRead line from stdin

Image Effects

See Effects for the full effect reference.

Parameterized (return a meme transform function):

blur(r), pixelate(s), noise(a), saturate(f), contrast(f), brightness(f), hueShift(d), glow(r), posterize(l), chromatic(o), threshold(l), tint(hex), jpeg(q)

Direct (take a meme, return a meme):

grayscale, sepia, invert, sharpen, vignette

Layout & Composition

FunctionSignatureReturnsDescription
besidebeside(left, right)MemeSide-by-side
stackstack(top, bottom)MemeVertical stack
gridgrid(cols, memes)MemeGrid arrangement
padpad(meme, px)MemeAdd white padding
borderborder(meme, px)MemeAdd black border

Animation

FunctionSignatureReturnsDescription
animateanimate(memes, ms)GifCreate GIF with uniform frame duration
toGridtoGrid(memes, cols, rows)MemeRender array to grid

I/O

FunctionSignatureReturnsDescription
savesave(target, path)boolSave meme/GIF to file