Category:Quackery
This programming language may be used to instruct a computer to perform a task.
See Also: |
|
---|
If you know Quackery, please write code for some of the tasks not implemented in Quackery.
Quackery is an open source, lightweight, entry level concatenative language for educational and recreational programming.
It is coded as a Python 3 function in about 50k of Pythonscript, half of which is a string of Quackery code.
The Quackery GitHub repository, which includes the Quackery manual "The Book of Quackery" as a pdf, is at github.com/GordonCharlton/Quackery.
About Quackery[edit]
The Quackiverse consists of operators (i.e. op-codes or "primitives"), numbers (BigInteger) and nests (dynamic arrays of operators, numbers and nests). They reside on either of two stacks, or in one of the two dictionaries of named items (operators, numbers and nests) that the Quackery compiler, build
, uses to translate written Quackscript into nests that can be evaluated with do
, the default behaviour, or added to either of the dictionaries.
[ build do ] is quackery
Quackery in a nutshell.
To compile this definition of quackery
, build
takes a string of Quackscript and turns it into a nest. The left and right brackets delimit a nest, which will contain pointers to the dictionary items called build
and do
, in that order. Quackery code is evaluated from left to right, one item after another, traversing a tree of nests in depth first order. Once build
has compiled the string, it passes the resultant nest via the Quackery stack, which is used to carry arguments and results from one word to the next, to do
for evaluation. The second stack, the return stack, manages do
's depth first traversal of nested nests.
The words is
, [
, and ]
are builders; they can be found in the builders dictionary, which extends the functionality of build
beyond building a flat nest for do
to evaluate. is
takes the item that do
most recently added to its output nest, and adds it to the names dictionary, along with the string that follows it, "quackery
" as its name. The syntax of Quackery is; words and numbers are sequences of printable characters, separated by spaces and carriage returns unless a builder treats the text that follows it otherwise. The builder builds
is equivalent to is
for adding new words and behaviours to the builders dictionary.
Evaluation of a nest proceeds from left to right unless a control flow operator redirects it. done
causes do
to stop evaluating a nest and return to the nest that pointed to it immediately, rather than at the end of the nest. again
restarts the evaluation of that nest, non-recursively. The word recurse
does it recursively. if
and iff
conditionally (depending on the item on the top of the Quackery stack) skip over the next one and two items in the nest respectively. else
skips over one item, unconditionally. As with the other provided control flow operators, these words are nests, not operators, that make use of the "meta-control flow" operators, which grant the behaviours described above to words that use them. (They modify items on the return stack, rather than acting on the Quackery engine's various pointers registers directly, so their changes are enacted upon exiting the nest that called them.)
There are no variables in Quackery. Instead there are stack management words to rearrange the uppermost items on the Quackery stack as required, and nameable ancillary stacks that fulfil the roles of variables.
Everything is code except when it is data. When do
does a number, the behaviour of the number is to put its numerical value on the stack. Operators do the heavy lifting; there are operators that treat numbers as integers, or as booleans, or as sequences of bits, or as characters, and there are operators to edit nests, interface with the real-world host computer for I/O, and so on. Nests give structure to code and data alike.
Conceptually, the Quackery engine is a stack based processor which does not have direct access to physical memory, but has a memory management co-processor that intermediates, that takes care of the nests and bignums, provides pointers to the Quackery engine CPU on request, and garbage collects continuously.
Quackery is not intended to be a super-fast enterprise level language; it is intended as a fun programming project straight out of a textbook. (The textbook is included in the download.)
If your language supports bignums, first class functions and dynamic arrays of bignums, functions and dynamic arrays, and has automatic garbage collection, and if you can code depth first traversal of a tree, you can implement Quackery in your preferred language with reasonable ease.
Pages in category "Quackery"
The following 475 pages are in this category, out of 475 total.
A
- A+B
- ABC problem
- ABC words
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Accumulator factory
- Ackermann function
- Additive primes
- Almkvist-Giullera formula for pi
- Almost prime
- Alternade words
- Amicable pairs
- Anagrams
- Anagrams/Deranged anagrams
- Angle difference between two bearings
- Anonymous recursion
- Anti-primes
- Apply a callback to an array
- Arbitrary-precision integers (included)
- Archimedean spiral
- Arithmetic-geometric mean
- Arithmetic/Integer
- Arithmetic/Rational
- Array concatenation
- Array length
- Arrays
- Ascending primes
- Attractive numbers
- Averages/Arithmetic mean
- Averages/Mode
- Averages/Pythagorean means
- Averages/Root mean square
- Averages/Simple moving average
B
C
- Caesar cipher
- Calculating the value of e
- Calkin-Wilf sequence
- Call a function
- Call an object method
- Camel case and snake case
- Cantor set
- Cartesian product of two or more lists
- Case-sensitivity of identifiers
- Casting out nines
- Catalan numbers
- Catalan numbers/Pascal's triangle
- Catamorphism
- Change e letters to i in words
- Character codes
- Check input device is a terminal
- Check output device is a terminal
- Church numerals
- Closures/Value capture
- Code Golf: Code Golf
- Combinations
- Combinations with repetitions
- Comma quibbling
- Comments
- Common list elements
- Common sorted list
- Compare a list of strings
- Compare length of two strings
- Compile-time calculation
- Compound data type
- Conditional structures
- Continued fraction
- Continued fraction/Arithmetic/Construct from rational number
- Convert decimal number to rational
- Convert seconds to compound duration
- Coprimes
- Copy a string
- Count how many vowels and consonants occur in a string
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- CRC-32
- Create a two-dimensional array at runtime
- Cullen and Woodall numbers
- Currying
- Curzon numbers
- CUSIP
- Cycle detection
- Cycles of a permutation
D
- Damm algorithm
- Day of the week
- Day of the week of Christmas and New Year
- Department numbers
- Determine if a string has all the same characters
- Determine if a string is collapsible
- Determine if a string is numeric
- Digital root
- Digital root/Multiplicative digital root
- Dot product
- Dragon curve
- Dynamic variable names
E
- Egyptian division
- Elementary cellular automaton
- Emirp primes
- Empty program
- Empty string
- Ethiopian multiplication
- Evaluate binomial coefficients
- Even or odd
- Exceptions
- Exceptions/Catch an exception thrown in a nested call
- Execute a system command
- Execute Brain****
- Execute HQ9+
- Exponentiation operator
- Exponentiation order
- Extend your language
- Extract file extension
F
- Factorial
- Factorial base numbers indexing permutations of a collection
- Factorions
- Factors of an integer
- Fairshare between two and more
- Farey sequence
- Fibonacci n-step number sequences
- Fibonacci sequence
- File input/output
- Filter
- Find limit of recursion
- Find prime n such that reversed n is also prime
- Find square difference
- Find the last Sunday of each month
- Find the missing permutation
- Find words whose first and last three letters are equal
- Find words with alternating vowels and consonants
- Five weekends
- FizzBuzz
- Flatten a list
- Floyd's triangle
- Forward difference
- Four sides of square
- Fractal tree
- Fractran
- Function composition
- Function definition
- Function prototype
- Fusc sequence
G
H
- Hailstone sequence
- Halt and catch fire
- Hamming numbers
- Happy numbers
- Harmonic series
- Harshad or Niven series
- Hello world/Newbie
- Hello world/Newline omission
- Hello world/Text
- Higher-order functions
- Hilbert curve
- History variables
- Hofstadter Q sequence
- Hofstadter-Conway $10,000 sequence
- Huffman coding
- Humble numbers
I
- Identity matrix
- Idiomatically determine all the characters that can be used for symbols
- Idiomatically determine all the lowercase and uppercase letters
- Include a file
- Increment a numerical string
- Index finite lists of positive integers
- Integer comparison
- Integer overflow
- Integer roots
- Integer sequence
- Interactive programming
- Intersecting number wheels
- ISBN13 check digit
- Isqrt (integer square root) of X
- Iterated digits squaring
L
- Lah numbers
- Largest int from concatenated ints
- Largest proper divisor of n
- Last Friday of each month
- Leap year
- Least common multiple
- Left factorials
- Leonardo numbers
- Letter frequency
- Linear congruential generator
- Literals/Integer
- Literals/String
- Logical operations
- Long literals, with continuations
- Long multiplication
- Long primes
- Long year
- Longest common prefix
- 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/Infinite
- Loops/N plus one half
- Loops/Nested
- Loops/While
- Luhn test of credit card numbers
M
- Machine code
- Magic 8-ball
- Magic constant
- Matrix transposition
- Matrix with two diagonals
- McNuggets problem
- Metaprogramming
- Mian-Chowla sequence
- Middle three digits
- Mind boggling card trick
- Modular arithmetic
- Modular exponentiation
- Modular inverse
- Monte Carlo methods
- Monty Hall problem
- Mosaic matrix
- Motzkin numbers
- Move-to-front algorithm
- Multifactorial
- Multiplication tables
- Munchausen numbers
- Mutual recursion
N
- N'th
- N-smooth numbers
- Names to numbers
- Naming conventions
- Narcissist
- Narcissistic decimal number
- Negative base numbers
- Nice primes
- Nimber arithmetic
- Non-continuous subsequences
- Non-decimal radices/Convert
- Number names
- Number reversal game
- Numbers divisible by their individual digits, but not by the product of their digits.
- Numbers in base-16 representation that cannot be written with decimal digits
- Numbers with same digit set in base 10 and base 16
- Numeric separator syntax
O
P
- Padovan sequence
- Palindrome detection
- Palindromic primes
- Palindromic primes in base 16
- Pangram checker
- Parsing/RPN calculator algorithm
- Partial function application
- Pascal's triangle
- Peano curve
- Pentagram
- Perfect numbers
- Perfect shuffle
- Perfect totient numbers
- Permutations
- Permutations with repetitions
- Permutations/Derangements
- Pernicious numbers
- Phrase reversals
- Pi
- Pick random element
- Pierpont primes
- Piprimes
- Playing cards
- Population count
- Power set
- Price fraction
- Primality by trial division
- Primality by Wilson's theorem
- Prime decomposition
- Priority queue
- Probabilistic choice
- Product of divisors
- Proper divisors
R
- Random number generator (included)
- Rare numbers
- Read entire file
- Recaman's sequence
- 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
- Roman numerals/Decode
- Roman numerals/Encode
- Rot-13
- RPG attributes generator
- Run-length encoding
- Runtime evaluation
- Ruth-Aaron numbers
S
- Sattolo cycle
- Self-describing numbers
- Self-hosting compiler
- Semiprime
- Semordnilap
- Sequence of non-squares
- Sequence of primes by trial division
- Sequence: smallest number greater than previous term with exactly n divisors
- Sequence: smallest number with exactly n divisors
- Set
- Seven-sided dice from five-sided dice
- Shell one-liner
- Shift list elements to left by 3
- Show ASCII table
- Show the (decimal) value of a number of 1s appended with a 3, then squared
- Sierpinski arrowhead curve
- Sierpinski carpet
- Sierpinski curve
- Sierpinski pentagon
- Sierpinski square curve
- Sierpinski triangle
- Sierpinski triangle/Graphical
- Sieve of Eratosthenes
- Simple turtle graphics
- Sleeping Beauty problem
- Smarandache prime-digital sequence
- Sort an integer array
- Sort numbers lexicographically
- Sort stability
- Sort three variables
- Sort using a custom comparator
- Sorting algorithms/Bogosort
- Sorting algorithms/Bubble sort
- Sorting Algorithms/Circle Sort
- Sorting algorithms/Counting sort
- Sorting algorithms/Gnome sort
- Sorting algorithms/Heapsort
- Sorting algorithms/Insertion sort
- Sorting algorithms/Merge sort
- Sorting algorithms/Pancake sort
- Sorting algorithms/Patience sort
- Sorting algorithms/Permutation sort
- Sorting algorithms/Quicksort
- Sorting algorithms/Radix sort
- Sorting algorithms/Selection sort
- Sorting algorithms/Stooge sort
- Special characters
- Special variables
- Spiral matrix
- Split a character string based on change of character
- Square but not cube
- Stack
- Stack traces
- Stair-climbing puzzle
- Start from a main routine
- Stern-Brocot sequence
- Stirling numbers of the first kind
- Stirling numbers of the second kind
- String append
- String case
- String comparison
- String concatenation
- String matching
- String prepend
- Strip a set of characters from a string
- Strip whitespace from a string/Top and tail
- Substitution cipher
- Substring
- Substring/Top and tail
- Sum and product of an array
- Sum digits of an integer
- Sum multiples of 3 and 5
- Sum of a series
- Sum of divisors
- Sum of first n cubes
- Sum of square and cube digits of an integer are primes
- Sum of squares
- Sylvester's sequence
- Symmetric difference
- System time
T
- Tau function
- Tau number
- Temperature conversion
- Terminal control/Clear the screen
- Terminal control/Cursor positioning
- Terminal control/Hiding the cursor
- Terminal control/Inverse video
- Terminal control/Ringing the terminal bell
- Ternary logic
- Test a function
- Test integerness
- The Twelve Days of Christmas
- Thue-Morse
- Tokenize a string
- Totient function
- Towers of Hanoi
- Tree from nesting levels
- Tree traversal
- Trigonometric functions
- Triplet of three numbers
- Truncatable primes
- Truth table
- Twin primes
- Two identical strings
- Two sum