Language docs

Core library

Reference for the derived stack, logic, and control-flow words exported by `ff/lib/core/core.ff`.

This page lists the public words currently defined in the top-level core library module.

core.ff

Source: ff/lib/core/core.ff
Import: .import <core/core>

WordStack effectDescription
true-- 1Pushes the canonical true value.
false-- 0Pushes the canonical false value.
--n -- n-1Decrements an integer by one.
++n -- n+1Increments an integer by one.
predn -- n n-1Duplicates a value and pushes its predecessor.
succn -- n n+1Duplicates a value and pushes its successor.
slip[A] b -- a* bRuns a quotation under the top value and restores that value afterward.
swapda b c -- b a cSwaps the lower two items of the top three.
dupda b -- a a bDuplicates the second item while leaving the top item in place.
drop2a b --Drops the top two values.
dipa [B] -- b* aRuns a quotation while temporarily stashing the top item.
dipda b [B] -- b* a bRuns a quotation under the top two items.
diga b c -- b c aRotates the third item to the top.
burya b c -- c a bRotates the top item below the next two items.
rota b c -- c b aReorders the top three values by reversing their outer positions.
overa b -- a b aCopies the second item to the top.
dup2a b -- a b a bDuplicates the top pair.
run[A] -- a* [A]Evaluates a quotation while leaving the quotation on the stack.
nipa b -- bRemoves the second item from the top pair.
tucka b -- b a bCopies the top item beneath the next item.
sipa [B] -- a b* aRuns a quotation with a copy of the preserved top item.
sipda [B] c -- a b* a cRuns sip one level deeper under the top item.
bia [B] [C] -- b cApplies two quotations to the same input value.
bi2a b [C] [D] -- c dApplies two quotations to the same input pair.
zero?n -- flagTests whether a value is zero.
notflag -- flag'Logical negation for truthy/falsey integer flags.
nz?n -- flagTests whether a value is non-zero.
truthy?n -- flagNormalizes a value to a truthiness flag.
falsey?n -- flagTests whether a value is falsey.
!=a b -- flagTests whether two values differ.
<=a b -- flagTests whether a is less than or equal to b.
>=a b -- flagTests whether a is greater than or equal to b.
sort2a b -- min maxOrders a pair from smaller to larger.
between?lo hi n -- flagTests whether a value lies between two bounds.
bxora b -- nComputes bitwise exclusive-or.
anda b -- flagReturns a truthy flag when both inputs are truthy.
ora b -- flagReturns a truthy flag when either input is truthy.
nanda b -- flagReturns the negation of and.
nora b -- flagReturns the negation of or.
or_elsea [B] [C] -- flagShort-circuits to true or evaluates a fallback quotation.
and_alsoa [B] [C] -- flagShort-circuits to false or evaluates a continuation quotation.
choosea b flag -- a or bSelects one of two values based on a flag.
brancha flag [B] [C] -- b* or c*Evaluates one of two quotations based on a flag.
empty?… -- … flagTests whether the data stack is empty.
pushtop… a -- a …Moves the top item to the bottom of the current stack.
loopa [B] n -- a b* [B]Repeats a quotation n times, leaving the quotation.
timesa [B] n -- a b*Repeats a quotation n times and discards the quotation.
seqa n [B] -- a b*Builds a sequence of repeated quotation applications from a seed value.
rangea b -- a..bExpands an inclusive integer range.
countn -- 1..nPushes the integers from 1 through n.