**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 August 2019, 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 668 pages are in this category, out of 668 total.

### A

- A+B
- Abbreviations, automatic
- Abbreviations, easy
- Abbreviations, simple
- ABC Problem
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Accumulator factory
- Ackermann function
- Active object
- AKS test for primes
- Align columns
- Aliquot sequence classifications
- Almost prime
- 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
- Attractive numbers
- 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
- 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
- Burrows–Wheeler transform

### C

- Caesar cipher
- Calculating the value of e
- Calendar
- Call a foreign-language function
- Call a function
- Call an object method
- 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
- Classes
- Closures/Value capture
- Collections
- Colour bars/Display
- Combinations
- Comma quibbling
- Command-line arguments
- Comments
- Compare a list of strings
- Compile-time calculation
- Compound data type
- Concurrent computing
- Conditional structures
- Conjugate transpose
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Convert decimal number to rational
- Convert seconds to compound duration
- Copy a string
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- Cramer's rule
- CRC-32
- Create a file
- Create a two-dimensional array at runtime
- 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
- Define a primitive data type
- Delete a file
- Department Numbers
- Detect division by zero
- Determinant and permanent
- Determine if a string is numeric
- Dice game probabilities
- Digital root
- Digital root/Multiplicative digital root
- Dinesman's multiple-dwelling problem
- Display a linear combination
- Distributed programming
- DNS query
- Documentation
- Dot product
- Dragon curve
- Draw a cuboid
- Draw a pixel
- Draw pixel 2
- Dynamic variable names

### E

- Eban numbers
- Echo server
- Egyptian division
- Egyptian fractions
- Element-wise operations
- Elementary cellular automaton
- Emirp primes
- Empty directory
- Empty program
- Empty string
- Enforced immutability
- Entropy
- Entropy/Narcissist
- Enumerations
- Environment variables
- Equilibrium index
- 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 HQ9+
- Execute SNUSP
- Exponentiation operator
- Exponentiation order
- Extend your language
- 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
- Farey sequence
- Fast Fourier transform
- Faulhaber's formula
- Faulhaber's triangle
- 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
- Filter
- Find common directory path
- Find limit of recursion
- Find palindromic numbers in both binary and ternary bases
- Find the last Sunday of each month
- Find the missing permutation
- 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
- General FizzBuzz
- Generate Chess960 starting position
- Generate lower case ASCII alphabet
- Generate random chess position
- Generator/Exponential
- Generic swap
- Get system command output
- Gray code
- Greatest common divisor
- Greatest element of a list
- Greatest subsequential sum
- Greed
- Guess the number
- Guess the number/With feedback

### 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/Newline omission
- Hello world/Standard error
- Hello world/Text
- Here document
- Heronian triangles
- Hickerson series of almost integers
- Higher-order functions
- History variables
- Hofstadter Figure-Figure sequences
- Hofstadter Q sequence
- Horizontal sundial calculations
- Horner's rule for polynomial evaluation
- Host introspection
- Hostname
- HTTP
- 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 Pairs of Numbers
- Integer comparison
- Integer sequence
- Interactive programming
- Intersecting Number Wheels
- Introspection
- Inverted index
- Inverted syntax
- Iterated digits squaring

### 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
- Leonardo numbers
- Letter frequency
- Levenshtein distance
- List comprehensions
- Literals/Floating point
- Literals/Integer
- Literals/String
- Logical operations
- Long multiplication
- Long primes
- Longest common prefix
- Longest common subsequence
- 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

- Mad Libs
- Magic 8-Ball
- Magic squares of doubly even order
- Magic squares of odd order
- Make directory path
- Mandelbrot set
- Map range
- Matrix multiplication
- Matrix transposition
- Matrix-exponentiation operator
- Maximum triangle path sum
- Mayan numerals
- McNuggets Problem
- MD5
- Memory allocation
- Menu
- Mersenne primes
- Metronome
- Middle three digits
- Mind boggling card trick
- 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
- Multifactorial
- Multiline shebang
- Multiple distinct objects
- Multiplication tables
- Munchausen numbers
- Munching squares
- Mutual recursion

### N

- N'th
- N-queens problem
- N-smooth numbers
- Named parameters
- Naming conventions
- Narcissistic decimal number
- Nested function
- Nested templated data
- Nim Game
- Non-decimal radices/Convert
- Non-decimal radices/Input
- Non-decimal radices/Output
- Nth root
- Null object
- Number names
- Number reversal game
- Numeric separator syntax
- Numerical and alphabetical suffixes
- Numerical integration
- Numerical integration/Adaptive Simpson's method

### O

### P

- Palindrome detection
- Pangram checker
- Parallel calculations
- Parsing/RPN calculator algorithm
- Partial function application
- Partition an integer X into N primes
- Pascal matrix generation
- Pascal's triangle
- Pascal's triangle/Puzzle
- Pathological floating point problems
- 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
- Playing cards
- Poker hand analyser
- Polymorphic copy
- Polymorphism
- Polynomial long division
- Population count
- Power set
- Price fraction
- Primality by trial division
- Prime conspiracy
- Prime decomposition
- Primorial numbers
- Priority queue
- Probabilistic choice
- Program name
- Proper divisors
- 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
- 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
- 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
- Search a list
- Search a list of records
- SEDOLs
- Self-describing numbers
- Self-referential sequence
- 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 puzzle
- Seven-sided dice from five-sided dice
- Sexy primes
- SHA-1
- SHA-256
- Shell one-liner
- Shoelace formula for polygonal area
- Short-circuit evaluation
- Shortest common supersequence
- Show Ascii table
- Show the epoch
- 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/Merge sort
- Sorting algorithms/Permutation sort
- Sorting algorithms/Quicksort
- Sorting algorithms/Selection sort
- Sorting algorithms/Sleep sort
- Sorting algorithms/Stooge sort
- Soundex
- 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
- Statistics/Basic
- 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 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
- 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
- Super-d numbers
- Symmetric difference
- System time

### T

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