Wiki: Factor

Tips for golfing in Factor on codegolf.stackexchange.com

See the official handbook for docs and to search for words. Note that the docs represent the latest development version, and so might differ occasionally from the stable version used by code.golf.

Imports

Code.golf uses Factor stable release 0.99 with the extras vocab root removed. You can see if a vocab is available by looking at its docs page, under the Files section. If the file paths begin with resource:extra/, then that vocab is not available on code.golf. For example.

Code.golf runs in "auto-use" mode, so many vocabularies will be automatically imported when a word in that vocab is used. Some vocabs will not automatically import, in which case they must be explicitly imported using: USE: some-vocab, or for multiple vocabs: USING: vocab1 vocab2 ;.

Name clashes

Sometimes words will fail to load even other the vocabulary itself does automatically load. This happens when multiple different, auto-use vocabs all contain words with the same name. This can be resolved by either importing the desired vocab beforehand (explicitly or implicitly), or using the qualified form of the word (eg ascii:>lower).

Strings

Strings in factors are just sequences of integers. This means you can (usually) treat a string as an array, or an array as a string.

To use character point 0 in a string, use the escape code \0. Strings in Factor are multi-line, so \n can be replaced with literal newlines.

Useful words / other tips

Useful vocabs