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
In Factor this is a data flow pattern called <code>bi</code>.
```factor
[ 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
*Factor programming language *Planet Factor *Factor on concatenative.org *Factor on Wikipedia
Tasks
- 100 doors
- 2048
- 24 game
- 24 game/Solve
- 4-rings or 4-squares puzzle
- A+B
- ABC Problem
- AKS test for primes
- Abbreviations, automatic
- Abbreviations, easy
- Abbreviations, simple
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Accumulator factory
- Ackermann function
- Active object
- Align columns
- Aliquot sequence classifications
- Almost prime
- Amb
- Amicable pairs
- Anagrams/Deranged anagrams
- Angle difference between two bearings
- Angles (geometric), normalization and conversion
- Animate a pendulum
- Animation
- 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
- 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/Bézier curves/Cubic
- Bitmap/Bézier curves/Quadratic
- Bitwise operations
- Boolean values
- Box the compass
- Brazilian numbers
- Break OO privacy
- Bresenham's Line Algorithm
- Brownian tree
- Bulls and cows
- Burrows–Wheeler transform
- CRC-32
- CSV data manipulation
- CSV to HTML translation
- CUSIP
- Caesar cipher
- Calculating the value of e
- Calendar
- Call a foreign-language function
- Call a function
- Call an object method
- 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
- Create a file
- Create a two-dimensional array at runtime
- Cuban primes
- Cumulative standard deviation
- Currency
- Currying
- DNS query
- Damm algorithm
- Date format
- Date manipulation
- Day of the week
- Days between dates
- 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
- Documentation
- Dot product
- Dragon curve
- Draw a cuboid
- Draw a pixel
- Draw pixel 2
- Dynamic variable names
- 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 HQ9+
- Execute SNUSP
- Execute a system command
- Exponentiation operator
- Exponentiation order
- Extend your language
- Extract file extension
- Extreme floating point values
- Factorial
- Factorial base numbers indexing permutations of a collection
- Factorions
- Factors of a Mersenne number
- Farey sequence
- Fast Fourier transform
- Faulhaber's formula
- Faulhaber's triangle
- Fibonacci n-step number sequences
- Fibonacci sequence
- Fibonacci word
- Fibonacci word/fractal
- 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
- 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
- Guess the number
- Guess the number/With feedback
- HTTP
- Hamming numbers
- Happy numbers
- Harshad or Niven series
- Hash from two arrays
- Haversine formula
- Hello world!
- 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
- Humble numbers
- 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
- JSON
- Jaro distance
- Jensen's Device
- Jewels and Stones
- JortSort
- Josephus problem
- Kaprekar numbers
- Kernighans large earthquake problem
- Knapsack problem/0-1
- Knapsack problem/Unbounded
- Knuth shuffle
- Koch curve
- Kronecker product
- Kronecker product based fractals
- 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/Wrong ranges
- Loops/with multiple ranges
- Lucas-Lehmer test
- Ludic numbers
- Luhn test of credit card numbers
- MD5
- 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
- Memory allocation
- Menu
- 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
- Move-to-front algorithm
- Multifactorial
- Multiline shebang
- Multiple distinct objects
- Multiplication tables
- Munchausen numbers
- Munching squares
- Mutual recursion
- 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
- Object serialization
- Odd word problem
- Old Russian measure of length
- Old lady swallowed a fly
- One of n lines in a file
- One-dimensional cellular automata
- OpenGL
- Operator precedence
- Order disjoint list items
- Order two numerical lists
- Ordered words
- 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
- Quaternion type
- Queue/Definition
- Queue/Usage
- Quickselect algorithm
- Quine
- RIPEMD-160
- RPG Attributes Generator
- 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
- Rock-paper-scissors
- Roman numerals/Decode
- Roman numerals/Encode
- Roots of a quadratic function
- Rosetta Code/Count examples
- Rot-13
- Run-length encoding
- Runtime evaluation
- Runtime evaluation/In an environment
- S-Expressions
- SEDOLs
- SHA-1
- SHA-256
- Safe primes and unsafe primes
- Sattolo cycle
- Search a list
- Search a list of records
- Self-describing numbers
- Self-referential sequence
- 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
- 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 Puzzle
- Sum and product of an array
- 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
- 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
- Trabb Pardo–Knuth algorithm
- Tree traversal
- Trigonometric functions
- Truncatable primes
- Truth table
- Two Sum
- Type detection
- URL decoding
- URL encoding
- Ulam spiral (for primes)
- Unbias a random generator
- Unicode variable names
- Validate International Securities Identification Number
- Vampire number
- Van Eck sequence
- Van der Corput sequence
- Variables
- Variadic function
- Vector
- Vector products
- Verify distribution uniformity/Naive
- Vibrating rectangles
- Vigenère cipher
- Visualize a tree
- Walk a directory/Non-recursively
- Walk a directory/Recursively
- Water collected between towers
- Web scraping
- Window creation
- Word frequency
- Word wrap
- Write entire file
- XML/Input
- XML/Output
- XML/XPath
- Y combinator
- Zeckendorf number representation
- Zero to the zero power
- Zig-zag matrix