**Factor**

This

**programming language**may be used to instruct a computer to perform a task.

Official website |
---|

Execution method: | Compiled (machine code) |
---|---|

Garbage collected: | Yes |

Parameter passing methods: | By reference |

Type safety: | Safe |

Type compatibility: | Duck |

Type expression: | Implicit |

Type checking: | Dynamic |

Lang tag(s): | factor |

See Also: |

**Your Help Needed**

If you know

**Factor**, please write code for some of the tasks not implemented in

**Factor**.

Factor is a stack-based, concatenative, general-purpose programming language with a focus on practicality.

Initially developed by Slava Pestov, Factor began life in 2003 as a scripting language written for a game. The implementation was originally an interpreter written in Java, but has since gained an optimizing compiler and has been rewritten in Factor with a minimal C++ core. Read more about Factor's implementation history here. As of June 2020, Factor is still being developed by several contributors, with the latest stable release in July 2018.

Factor is a stack language similar to, but of a higher level than, Forth. Factor is a concatenative language, meaning that rather than applying functions to arguments (applicative languages) to evaluate things, we compose functions to evaluate a single piece of data — the entire program up until that particular point. In Factor, the basic structure of data flow is function composition. That is, `foo bar baz`

is equivalent to `baz(bar(foo()))`

in an applicative language. This offers a nice left-to-right style of reading and data flow.

In Factor, we tend to name data flow operations rather than values. In an applicative language, you might write

var x = ...;

var y = foo(x);

var z = bar(x);

In Factor this is a data flow pattern called `bi`

.

[ foo ] [ bar ] bi

This says, "apply `foo`

to the object at the top of the data stack, and apply `bar`

to it as well." Rather than naming the values `x`, `y`, and `z`, we named the data flow pattern.

Factor comes with many practical features, including a REPL, a self-contained help browser, an object inspector, a debugger/code walker, a deployment tool, editor integration for most popular text editors and IDEs, and introspection capabilities useful for developers. Factor has a fully-featured library, including things such as an HTTP server/client, bindings to graphics libraries and databases, a C FFI, a cross-platform GUI framework, on down to niche things like polynomial arithmetic. Factor features an object system that takes inspiration from Common Lisp and Self.

Most code tends to be expressed naturally in a functional manner. Factor comes with combinators (higher-order functions) typically seen in functional languages, such as `map`

, `filter`

, `reduce`

, and many more. Although most things can be done efficiently without mutation, Factor doesn't shy away from it when it's useful. Mutating words end with exclamation points (by convention). Factor provides lexical and dynamic variables which can make writing imperative code more natural, or allows one to clean up code that performs a lot of stack shuffling.

One of Factor's greatest strengths is its ability to factor words into smaller words. Due to the nature of concatenative programming, this is typically a cut and paste job that can be done almost anywhere there is whitespace. Factor also has impressive metaprogramming capabilities. Since Factor is almost entirely written in Factor, there is full introspection support, including seamless access to Factor's parser, allowing one to define new syntax. Factor also offers Lisp-style macros, and in general, Factor code can be treated like a collection (homoiconicity).

## Links[edit]

## Subcategories

This category has the following 3 subcategories, out of 3 total.

## Pages in category "Factor"

The following 808 pages are in this category, out of 808 total.

### A

- A+B
- Abbreviations, automatic
- Abbreviations, easy
- Abbreviations, simple
- ABC problem
- Abelian sandpile model/Identity
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Accumulator factory
- Ackermann function
- Active object
- AKS test for primes
- Align columns
- Aliquot sequence classifications
- Almkvist-Giullera formula for pi
- Almost prime
- Alternade words
- Amb
- Amicable pairs
- Anagrams
- Anagrams/Deranged anagrams
- Angle difference between two bearings
- Angles (geometric), normalization and conversion
- Animate a pendulum
- Animation
- Anonymous recursion
- Anti-primes
- Apply a callback to an array
- Approximate equality
- Arbitrary-precision integers (included)
- Arithmetic evaluation
- Arithmetic-geometric mean
- Arithmetic/Complex
- Arithmetic/Integer
- Arithmetic/Rational
- Array concatenation
- Array length
- Arrays
- Assertions
- Associative array/Creation
- Associative array/Iteration
- Associative array/Merging
- Attractive numbers
- Average loop length
- Averages/Arithmetic mean
- Averages/Mean angle
- Averages/Mean time of day
- Averages/Median
- Averages/Mode
- Averages/Pythagorean means
- Averages/Root mean square
- Averages/Simple moving average

### B

- Babbage problem
- Balanced brackets
- Base64 decode data
- Base64 encode data
- Bell numbers
- Benford's law
- Bernoulli numbers
- Binary digits
- Binary search
- Binary strings
- Bioinformatics/base count
- Bioinformatics/Sequence mutation
- Biorhythms
- Bitcoin/address validation
- Bitcoin/public point to address
- Bitmap
- Bitmap/Bresenham's line algorithm
- Bitmap/Bézier curves/Cubic
- Bitmap/Bézier curves/Quadratic
- Bitwise operations
- Boolean values
- Box the compass
- Brazilian numbers
- Break OO privacy
- Brownian tree
- Bulls and cows
- Bulls and cows/Player
- Burrows–Wheeler transform

### C

- Caesar cipher
- Calculating the value of e
- Calendar
- Call a foreign-language function
- Call a function
- Call an object method
- Canonicalize CIDR
- Cantor set
- Carmichael 3 strong pseudoprimes
- Cartesian product of two or more lists
- Case-sensitivity of identifiers
- Catalan numbers
- Catalan numbers/Pascal's triangle
- Catamorphism
- Chaocipher
- Character codes
- Check Machin-like formulas
- Check output device is a terminal
- Check that file exists
- Chemical calculator
- Cheryl's birthday
- Chinese remainder theorem
- Chinese zodiac
- Chowla numbers
- Circles of given radius through two points
- Circular primes
- Cistercian numerals
- Classes
- Closures/Value capture
- Collections
- Colour bars/Display
- Colour pinstripe/Display
- Combinations
- Combinations and permutations
- Comma quibbling
- Command-line arguments
- Commatizing numbers
- Comments
- Compare a list of strings
- Compile-time calculation
- Compound data type
- Concurrent computing
- Conditional structures
- Conjugate transpose
- Constrained random points on a circle
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Convert decimal number to rational
- Convert seconds to compound duration
- Copy a string
- Copy stdin to stdout
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- Cramer's rule
- CRC-32
- Create a file
- Create a file on magnetic tape
- Create a two-dimensional array at runtime
- Create an HTML table
- CSV data manipulation
- CSV to HTML translation
- Cuban primes
- Cumulative standard deviation
- Currency
- Currying
- CUSIP
- Cycle detection

### D

- Damm algorithm
- Date format
- Date manipulation
- Day of the week
- Days between dates
- Deal cards for FreeCell
- Decimal floating point number to binary
- Deepcopy
- Define a primitive data type
- Delete a file
- Deming's Funnel
- Department numbers
- Detect division by zero
- Determinant and permanent
- Determine if a string has all the same characters
- Determine if a string has all unique characters
- Determine if a string is collapsible
- Determine if a string is numeric
- Determine if a string is squeezable
- Dice game probabilities
- Digital root
- Digital root/Multiplicative digital root
- Dinesman's multiple-dwelling problem
- Display a linear combination
- Distributed programming
- Diversity prediction theorem
- DNS query
- Documentation
- Dot product
- Doubly-linked list/Element definition
- Dragon curve
- Draw a cuboid
- Draw a pixel
- Draw a sphere
- Draw pixel 2
- Dutch national flag problem
- Dynamic variable names

### E

- Eban numbers
- Echo server
- Egyptian division
- Egyptian fractions
- EKG sequence convergence
- Element-wise operations
- Elementary cellular automaton
- Emirp primes
- Empty directory
- Empty program
- Empty string
- Enforced immutability
- Entropy
- Entropy/Narcissist
- Enumerations
- Environment variables
- Equilibrium index
- Esthetic numbers
- Ethiopian multiplication
- Euler method
- Euler's identity
- Euler's sum of powers conjecture
- Evaluate binomial coefficients
- Even or odd
- Evolutionary algorithm
- Exceptions
- Exceptions/Catch an exception thrown in a nested call
- Executable library
- Execute a system command
- Execute Brain****
- Execute HQ9+
- Execute SNUSP
- Exponentiation operator
- Exponentiation order
- Exponentiation with infix operators in (or operating on) the base
- Extend your language
- Extensible prime generator
- Extra primes
- Extract file extension
- Extreme floating point values

### F

- Factorial
- Factorial base numbers indexing permutations of a collection
- Factorions
- Factors of a Mersenne number
- Factors of an integer
- Fairshare between two and more
- Farey sequence
- Fast Fourier transform
- FASTA format
- Faulhaber's formula
- Faulhaber's triangle
- Feigenbaum constant calculation
- Fermat numbers
- Fibonacci n-step number sequences
- Fibonacci sequence
- Fibonacci word
- Fibonacci word/fractal
- File extension is in extensions list
- File input/output
- File modification time
- File size
- File size distribution
- Filter
- Find common directory path
- Find if a point is within a triangle
- Find limit of recursion
- Find palindromic numbers in both binary and ternary bases
- Find the intersection of a line with a plane
- Find the intersection of two lines
- Find the last Sunday of each month
- Find the missing permutation
- First class environments
- First perfect square in base n with n unique digits
- First power of 2 that has leading decimal digits of 12
- First-class functions
- First-class functions/Use numbers analogously
- Five weekends
- Fivenum
- FizzBuzz
- Flatten a list
- Floyd's triangle
- Forest fire
- Fork
- Formatted numeric output
- Forward difference
- Four is magic
- Fractran
- Function composition
- Function definition
- Function frequency
- Fusc sequence

### G

- Galton box animation
- Gamma function
- Gapful numbers
- Gauss-Jordan matrix inversion
- General FizzBuzz
- Generate Chess960 starting position
- Generate lower case ASCII alphabet
- Generate random chess position
- Generator/Exponential
- Generic swap
- Geohash
- Get system command output
- Globally replace text in several files
- Gray code
- Grayscale image
- Greatest common divisor
- Greatest element of a list
- Greatest subsequential sum
- Greed
- Guess the number
- Guess the number/With feedback
- Guess the number/With feedback (player)

### H

- Hailstone sequence
- Hamming numbers
- Happy numbers
- Harshad or Niven series
- Hash from two arrays
- Haversine formula
- Hello world/Graphical
- Hello world/Line printer
- Hello world/Newbie
- Hello world/Newline omission
- Hello world/Standard error
- Hello world/Text
- Here document
- Heronian triangles
- Hickerson series of almost integers
- Higher-order functions
- Hilbert curve
- History variables
- Hofstadter Figure-Figure sequences
- Hofstadter Q sequence
- Hofstadter-Conway $10,000 sequence
- Holidays related to Easter
- Horizontal sundial calculations
- Horner's rule for polynomial evaluation
- Host introspection
- Hostname
- HTTP
- Huffman coding
- Humble numbers

### I

- I before E except after C
- IBAN
- Identity matrix
- Idiomatically determine all the characters that can be used for symbols
- Idiomatically determine all the lowercase and uppercase letters
- Image noise
- Include a file
- Increment a numerical string
- Infinity
- Inheritance/Multiple
- Inheritance/Single
- Input loop
- Input/Output for lines of text
- Input/Output for pairs of numbers
- Integer comparison
- Integer overflow
- Integer roots
- Integer sequence
- Interactive help
- Interactive programming
- Intersecting number wheels
- Introspection
- Inverted index
- Inverted syntax
- ISBN13 check digit
- Isqrt (integer square root) of X
- Iterated digits squaring

### J

### K

### L

- Lah numbers
- Largest int from concatenated ints
- Largest number divisible by its digits
- Last Friday of each month
- Law of cosines - triples
- Leap year
- Least common multiple
- Left factorials
- Length of an arc between two angles
- Leonardo numbers
- Letter frequency
- Levenshtein distance
- Linear congruential generator
- List comprehensions
- Literals/Floating point
- Literals/Integer
- Literals/String
- Logical operations
- Long literals, with continuations
- Long multiplication
- Long primes
- Long year
- Longest common prefix
- Longest common subsequence
- Longest common substring
- Longest common suffix
- Look-and-say sequence
- Loop over multiple arrays simultaneously
- Loops/Break
- Loops/Continue
- Loops/Do-while
- Loops/Downward for
- Loops/For
- Loops/For with a specified step
- Loops/Foreach
- Loops/Increment loop index within loop body
- Loops/Infinite
- Loops/N plus one half
- Loops/Nested
- Loops/While
- Loops/With multiple ranges
- Loops/Wrong ranges
- Lucas-Lehmer test
- Ludic numbers
- Luhn test of credit card numbers

### M

- MAC Vendor Lookup
- Mad Libs
- Magic 8-ball
- Magic squares of doubly even order
- Magic squares of odd order
- Magnanimous numbers
- Make directory path
- Mandelbrot set
- Map range
- Markov chain text generator
- Matrix multiplication
- Matrix transposition
- Matrix-exponentiation operator
- Maximum triangle path sum
- Mayan numerals
- McNuggets problem
- MD5
- Memory allocation
- Menu
- Mersenne primes
- Mertens function
- Metallic ratios
- Metered concurrency
- Metronome
- Mian-Chowla sequence
- Middle three digits
- Mind boggling card trick
- Minimum positive multiple in base 10 using only 0 and 1
- Minkowski question-mark function
- Modular arithmetic
- Modular exponentiation
- Modular inverse
- Modulinos
- Monads/List monad
- Monads/Maybe monad
- Monads/Writer monad
- Monte Carlo methods
- Morse code
- Mouse position
- Move-to-front algorithm
- Multi-dimensional array
- Multifactorial
- Multiline shebang
- Multiple distinct objects
- Multiplication tables
- Multiplicative order
- Multisplit
- Munchausen numbers
- Munching squares
- Mutual recursion
- Möbius function

### N

- N'th
- N-queens problem
- N-smooth numbers
- Named parameters
- Names to numbers
- Naming conventions
- Narcissistic decimal number
- Negative base numbers
- Nested function
- Nested templated data
- Next highest int from digits
- Nim game
- Nimber arithmetic
- Non-decimal radices/Convert
- Non-decimal radices/Input
- Non-decimal radices/Output
- Non-transitive dice
- Nth root
- Null object
- Number names
- Number reversal game
- Numbers with equal rises and falls
- Numbers with prime digits whose sum is 13
- Numeric error propagation
- Numeric separator syntax
- Numerical and alphabetical suffixes
- Numerical integration
- Numerical integration/Adaptive Simpson's method

### O

### P

- Palindrome dates
- Palindrome detection
- Palindromic gapful numbers
- Pangram checker
- Parallel calculations
- Parsing/RPN calculator algorithm
- Partial function application
- Partition an integer x into n primes
- Partition function P
- Pascal matrix generation
- Pascal's triangle
- Pascal's triangle/Puzzle
- Password generator
- Pathological floating point problems
- Peano curve
- Pell's equation
- Penney's game
- Percolation/Mean cluster density
- Percolation/Mean run density
- Percolation/Site percolation
- Perfect numbers
- Perfect shuffle
- Perfect totient numbers
- Perlin noise
- Permutations
- Permutations with some identical elements
- Permutations/Derangements
- Pernicious numbers
- Phrase reversals
- Pi
- Pick random element
- Pierpont primes
- Pisano period
- Playing cards
- Plot coordinate pairs
- Poker hand analyser
- Polymorphic copy
- Polymorphism
- Polynomial long division
- Population count
- Power set
- Pragmatic directives
- Price fraction
- Primality by trial division
- Primality by Wilson's theorem
- Prime conspiracy
- Prime decomposition
- Primorial numbers
- Priority queue
- Probabilistic choice
- Program name
- Proper divisors
- Pseudo-random numbers/Combined recursive generator MRG32k3a
- Pseudo-random numbers/PCG32
- Pseudo-random numbers/Splitmix64
- Pseudo-random numbers/Xorshift star
- Pythagorean triples

### R

- Random Latin squares
- Random number generator (device)
- Random number generator (included)
- Random numbers
- Range expansion
- Range extraction
- Ranking methods
- Ray-casting algorithm
- Read a file character by character/UTF8
- Read a file line by line
- Read a specific line from a file
- Read entire file
- Real constants and functions
- Reduced row echelon form
- Reflection/Get source
- Reflection/List methods
- Reflection/List properties
- Regular expressions
- Remove duplicate elements
- Remove vowels from a string
- Rename a file
- Rep-string
- Repeat
- Repeat a string
- Return multiple values
- Reverse a string
- Reverse words in a string
- RIPEMD-160
- Rock-paper-scissors
- Roman numerals/Decode
- Roman numerals/Encode
- Roots of a quadratic function
- Roots of unity
- Rosetta Code/Count examples
- Rot-13
- RPG attributes generator
- Run-length encoding
- Runtime evaluation
- Runtime evaluation/In an environment

### S

- S-expressions
- Safe primes and unsafe primes
- Sattolo cycle
- Scope/Function names and labels
- Search a list
- Search a list of records
- SEDOLs
- Self-describing numbers
- Semiprime
- Semordnilap
- Send an unknown method call
- Send email
- Sequence of non-squares
- Sequence of primes by trial division
- Sequence of primorial primes
- Sequence: nth number with exactly n divisors
- Sequence: smallest number greater than previous term with exactly n divisors
- Sequence: smallest number with exactly n divisors
- Set
- Set consolidation
- Set puzzle
- Seven-sided dice from five-sided dice
- Sexy primes
- SHA-1
- SHA-256
- SHA-256 Merkle tree
- Shell one-liner
- Shoelace formula for polygonal area
- Short-circuit evaluation
- Shortest common supersequence
- Show ASCII table
- Show the epoch
- Sierpinski arrowhead curve
- Sierpinski carpet
- Sierpinski curve
- Sierpinski square curve
- Sierpinski triangle
- Sierpinski triangle/Graphical
- Sieve of Eratosthenes
- Simple windowed application
- Singleton
- Singly-linked list/Element definition
- Singly-linked list/Element insertion
- Singly-linked list/Traversal
- Sleep
- Smarandache prime-digital sequence
- Smith numbers
- Sockets
- Solve the no connection puzzle
- Sort a list of object identifiers
- Sort an array of composite structures
- Sort an integer array
- Sort disjoint sublist
- Sort numbers lexicographically
- Sort stability
- Sort three variables
- Sort using a custom comparator
- Sorting algorithms/Bead sort
- Sorting algorithms/Bogosort
- Sorting algorithms/Bubble sort
- Sorting algorithms/Cocktail sort
- Sorting algorithms/Gnome sort
- Sorting algorithms/Insertion sort
- Sorting algorithms/Merge sort
- Sorting algorithms/Permutation sort
- Sorting algorithms/Quicksort
- Sorting algorithms/Selection sort
- Sorting algorithms/Sleep sort
- Sorting algorithms/Stooge sort
- Soundex
- Sparkline in unicode
- Spelling of ordinal numbers
- Spinning rod animation/Text
- Spiral matrix
- Split a character string based on change of character
- Square but not cube
- Square-free integers
- Stack
- Stack traces
- Stair-climbing puzzle
- Start from a main routine
- Statistics/Basic
- Statistics/Normal distribution
- Stem-and-leaf plot
- Stern-Brocot sequence
- Stirling numbers of the first kind
- Stirling numbers of the second kind
- String append
- String case
- String comparison
- String concatenation
- String interpolation (included)
- String length
- String matching
- String prepend
- Strip a set of characters from a string
- Strip block comments
- Strip comments from a string
- Strip control codes and extended characters from a string
- Strip whitespace from a string/Top and tail
- Strong and weak primes
- Substitution cipher
- Substring
- Substring/Top and tail
- Successive prime differences
- Sum and product of an array
- Sum and product puzzle
- Sum data type
- Sum digits of an integer
- Sum multiples of 3 and 5
- Sum of a series
- Sum of squares
- Summarize and say sequence
- Super-d numbers
- Symmetric difference
- System time

### T

- Take notes on the command line
- Teacup rim text
- Temperature conversion
- Terminal control/Ringing the terminal bell
- Ternary logic
- Test a function
- Test integerness
- Text between
- Text completion
- Text processing/2
- Text processing/Max licenses in use
- Textonyms
- The Name Game
- The Twelve Days of Christmas
- Thue-Morse
- Time a function
- Tokenize a string
- Tokenize a string with escaping
- Top rank per group
- Topswops
- Totient function
- Towers of Hanoi
- Trabb Pardo–Knuth algorithm
- Tree traversal
- Trigonometric functions
- Truncatable primes
- Truth table
- Twin primes
- Two bullet roulette
- Two sum
- Type detection