Components

January 31, 2018 · View on GitHub

This is a list of all (currently implemented) components that are usable in an Ohm circuit.

Notes

Because of input restrictions, complex numbers are represented as an array in the form [real, imaginary].

Single character

ComponentActionDescription
°N/APushes an array of all given inputs.
¹N/AN/A
²Pop aPushes a squared.
³N/APushes the first input.
N/APushes the second input.
N/APushes the third input.
Pop aPushes the ath input (zero-indexed).
N/APushes 16.
N/APushes 100.
N/APushes the value of the counter variable.
N/AIncrements the counter variable.
N/ASets the counter variable to 0.
Pop a, bPushes whether a and b are equal. Does not vectorize.
Pop aPushes the first element in a. Does not vectorize.
Pop aPushes the last element in a. Does not vectorize.
Pop a, bPushes ab.
½Pop aPushes a / 2 (half).
N/AN/A
¼N/AN/A
Pop a, bPushes a.unshift(b).
Pop aPushes the maximum element in a.
Pop a, bPushes a.push(b).
Pop aPushes the minimum element in a.
Pop a, bPushes a.concat(b).
Pop aPushes the minimum and maximum element in a as an array of the form [min, max].
ıPop aPushes a rounded up to the nearest integer (ceiling).
ȷPop aPushes a rounded down to the nearest integer (floor).
×Pop a, bPushes a repeated b times.
÷Pop aPushes 1 / a (reciprocal).
£BlockRuns the given block infinitely.
¥Pop a, bPushes a % b == 0 (divisibility).
Pop a, blockPushes an array with the results of running the given block once for every element in a (map/collect).
!Pop aPushes a! (factorial).
"N/ACreates a string literal.
#Pop aPushes the range 0..a.
$N/APushes the current value of the register.
%Pop a, bPushes a % b (modulo).
&Pop a, bPushes a && b (boolean AND).
'Pop aPushes the character with char code a.
(Pop aPushes a without the first element.
)Pop aPushes a without the last element.
*Pop a, bPushes a * b (multiplication).
+Pop a, bPushes a + b (addition).
,Pop aPrints a to standard output (with trailing newline).
-Pop a, bPushes a - b (subtraction).
.N/ACreates a character literal (e.g. .a'a').
/Pop a, bPushes a / b (division).
Digits 0-9N/ACreates a number literal.
:Pop a, blockExecutes the given block for each element in a (foreach loop).
<Pop a, bPushes a < b (less than).
=Get aPrints a to standard output (with trailing newline).
>Pop a, bPushes a > b (greater than).
?Pop a, blockIf a is truthy, executes the given block. If not, executes the block given to the ¿ component if one is present.
@Pop aPushes the range 1..a.
APop aPushes the absolute value of a.
BPop a, bPushes a converted to base b.
CN/AN/A
DPop aPushes a twice (duplicate).
EPop a, bPushes a == b (equality).
FN/AN/A
GPop a, bPushes the range a..b.
HPop a, bPushes a split on spaces.
IN/APushes input from standard input.
JPop aIf a is an array, pushes a.join(''), else pushes stack.join('').
KPop a, bPushes the amount of times that b occurs in a.
LPop aPrints a to standard output (without trailing newline).
MPop a, blockRuns the given block a times.
NPop a, bPushes a != b (inequality).
ON/ARemoves last element of stack.
PPop aPushes all primes up to a.
QN/AReverses stack.
RPop aPushes a reversed.
SPop aPushes a sorted.
TN/AN/A
UPop aPushes a uniquified.
VPop aPushes divisors of a.
WN/APushes [stack] (wrap).
XPop aPushes !a (boolean NOT).
YPop aPushes proper divisors of a.
ZPop aPushes a split on newlines.
[Pop aPushes stack[a].
\Pop a, b, cPushes a with all matches of regex b replaced by c.
]Pop aFlattens a by one level onto the stack.
^N/APushes index of current element in array being looped over.
_N/APushes current element in array being looped over.
`Pop aPushes char code of a.
aPop a, bPushes absolute difference of a and b.
bPop aPushes a in binary (base 2).
cPop a, bPushes a nCr b (binomial coefficient).
dPop aPushes a * 2 (double).
ePop a, bPushes a nPr b (permutations).
fPop aPushes all Fibonacci numbers up to a.
gPop a, bPushes the range a...b.
hPop aPushes the first element of a.
iPop aPushes the last element of a.
jPop a, bIf a is an array, pushes a.join(b), else pushes stack.join(b).
kPop a, bPushes index of b in a.
lPop aPushes length of a.
mPop aPushes prime factors of a.
nPop aPushes exponents of prime factorization of a.
oPop aPushes full prime factorization of a.
pPop aPushes whether a is a prime number.
qN/AImmediately stops program execution.
rPop a, b, cPushes a.tr(b, c).
sPop a, bPushes b, a (swap).
tPop a, bPushes a converted to base 10 from base b.
uPop aPushes a as a string.
vPop a, bPushes a // b (integer/floor division).
wPop aPushes [a] (wrap).
xPop aPushes a in hexadecimal (base 16).
yPop aPushes the sign of a (1 if positive, -1 if negative, 0 if zero).
zPop aPushes a without surrounding whitespace.
{Pop aDeep flattens a.
|Pop a, bPushes a || b (boolean OR).
}Pop aPushes a split into slices of 1 (shorthand for ).
~Pop aPushes -a (negative).
N/AAlternate character for newline (\n).
βPop a, bPushes a split into b groups.
γPop aPushes all possible rotations of a.
δPop aPushes an array of the differences between consecutive elements in a.
εPop a, bPushes whether b is in a.
ζPop aPushes the first and last elements of a as an array.
ηPop aPushes if a is empty.
θPop a, b, cPushes a[b..c] (slice arbitrarily).
ιPop a, bPushes a[0..b] (slice from beginning).
κPop a, bPushes a[b..a.length] (slice from end).
λPop aPushes a rotated once to the left.
μPop a, bPushes the Cartesian product of a and b.
νPop a, bPushes whether b is in a. Does not vectorize.
ξPop aPushes a three times (triplicate).
πPop aPushes the ath prime number.
ρPop aPushes a rotated once to the right.
ςPop a, blockPushes a sorted by the results of running the given block once for each element in a.
σPop a, bPushes a split into groups of length b.
τN/APushes 10.
φPop aPushes the Euler totient/phi function of a.
χPop a, blockPushes the elements in a that return the minimum and maximum value from the given block.
ψPop aPushes all permutations of a.
ωPop aPushes the power set of a.
ΓN/APushes -1.
ΔPop aPushes an array of the absolute differences between consecutive elements in a.
ΘN/AExecutes the wire at the index before the current one.
ΠPop aIf a is an array, pushes the total product of a, else pushes the total product of the stack.
ΣPop aIf a is an array, pushes the total sum of a, else pushes the total sum of the stack.
ΦPop aExecutes the wire at index a.
ΨN/AExecutes the current wire. (Great for recursion!)
ΩN/AExecutes the wire at the index after the current one.
ÀPop aPushes a in all lower-case.
ÁPop aPushes a in all upper-case.
ÂPop aPushes a in title-case.
ÃPop aPushes a with swapped capitalization.
ÄPop a, bPushes a onto the stack b times.
ÅPop a, blockPushes whether all the elements in a return a truthy value from the given block.
ĀPop aPushes a with the first letter capitalized.
ÈN/AN/A
ÉPop aPushes whether any of the elements in a return a truthy value from the given block.
ÊN/AN/A
ËN/AN/A
ÌN/AN/A
ÍN/AN/A
ÎN/AN/A
ÏN/AN/A
ÒN/AN/A
ÓN/AN/A
ÔN/AN/A
ÕN/AN/A
ÖPop aPushes the run-length encoding of a (i.e. "aabbbcca" => [["a", 2], ["b", 3], ["c", 2], ["a", 1]]).
ØPop aPushes a grouped by identical (consecutive) elements.
ŒPop aPushes a randomly shuffled.
ÙPop a, bPushes a with b spaces appended.
ÚPop a, bPushes a with b spaces prepended.
ÛPop a, bPushes a left-justified to length b (with spaces).
ÜPop a, bPushes a right-justified to length b (with spaces).
ÇPop a, bPushes an array of every consecutive group of b elements in a.
ÐN/APushes a space character ( ).
ÑN/APushes a newline character (\n).
ÝN/APushes an empty string ('').
ÞN/APushes an empty array ([]).
àPop a, bPushes a & b (bitwise AND).
áPop a, bPushes a | b (bitwise OR).
âPop a, bPushes a ^ b (bitwise XOR).
ãPop aPushes ~a (bitwise NOT).
äPop aPushes the prime factorization of a as a list of [prime, exponent] pairs.
åN/AN/A
āN/AN/A
æPop aPushes a as a palindrome.
èPop aPushes a % 2 != 0 (odd).
éPop aPushes a % 2 == 0 (even).
êPop aPushes the first a Fibonacci numbers.
ëPop aPushes the first a prime numbers.
ìPop aPushes a as an integer.
íPop aPushes a as a float.
îPop aPushes if a is an integer.
ïPop a, bPushes a.split(b).
òPop aPushes a zipped.
óPop aPushes a converted to base 10 from binary (base 2).
ôPop aPushes a converted to base 10 from hexadecimal (base 16).
õN/AN/A
öPop aPushes the run-length decoding of a (i.e. [["a", 2], ["b", 3], ["c", 2], ["a", 1]] => "aabbbcca").
øPop a, bPushes an array of size b filled with a.
œPop aPushes [a, a.reverse].
ùPop aIf a is an array, pushes a.join(' '), else pushes stack.join(' ').
úPop aIf a is an array, pushes a.join("\n"), else pushes stack.join("\n").
ûPop a, b, cPushes the range between a and b in steps of c.
üN/AN/A
çPop a, bPushes all possible combinations of b elements in a.
ðPop aPushes a == a.reverse (palindrome).
ñPop aPushes whether a is a Fibonacci number.
ýPop aPushes the ath Fibonacci number.
þPop aSleeps execution for a seconds.
¿BlockElse statement for use with the ? component.
Pop aIf a is truthy, breaks out of the current block/wire.
Pop a, blockPushes an array containing all elements of a for which the given block returns a truthy value (filter/select).
Pop a, blockPushes a 2D array in which the first element contains all the elements of a that returned a truthy value from the given block and the second element contains all the elements of a that returned falsy (partition).
Pop a, blockSame as , except with falsy values instead of truthy ones.
¡Pop a, componentPushes the final result of reducing the given component over a, using the first element of a as the initial memo. Equivalent to foldl1 in Haskell.
Pop aPushes 2a.
Pop aPushes 10a.
¦Pop aPushes a rounded to the nearest integer.
§Pop aPushes a random element from a.
©Pop aPushes a repeated twice (string duplicate).
®Pop aPushes a[b] (element at index).
±Pop a, bPushes the bth root of a.
¬Pop aPushes the square root of a.
¢Get aSets the value of the register to a.
¤Pop a, componentSame as ¡, except pushes the array of intermediate results. Equivalent to scanl1 in Haskell.
«Pop a, bPushes [a, b] (pair).
»Pop a, componentPushes an array containing the results of applying the given component for each element in a.
Pop aPushes a - 1 (decrement).
Pop aPushes a + 1 (increment).
N/ACreates a base-255 number literal.
N/ACreates a compressed string literal.
Pop a, blockPushes the element in a that returns the minimum value from the given block.
Pop a, blockSame as , except with the maximum value instead of minimum.
N/ACreates a two-character literal (e.g. ‥ab => 'ab').
N/ACreates a three-character literal (e.g. …abc => 'abc').
N/ACreates a code page indexes literal (e.g. ᠁?¿᠁ => [63, 224])
Pop a, bPushes the set intersection of a and b.
Pop a, bPushes the set union of a and b.
N/AN/A
Pop a, bPushes set difference of a and b.

Multi-character

Constants (α)

ComponentDescription
α0Pushes all the digits from 0-9 (0123456789).
α1Pushes all the digits from 1-9 (123456789).
α@Pushes all the printable ASCII characters ( to ~).
αAPushes the normal uppercase alphabet (ABCDEFGHIJKLMNOPQRSTUVWXYZ).
αCPushes all the consonants (BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz).
aQPushes the uppercase alphabet ordered as it is on a keyboard (['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM']).
αWPushes all the tokens that match the \w regex metachar (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_).
αYPushes all the consonants without y (BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz).
αaPushes the normal lowercase alphabet (abcdefghijklmnopqrstuvwxyz).
αcPushes all the vowels (AEIOUaeiou).
αePushes Euler's constant e (2.7182818...).
αqPushes the lowercase alphabet ordered as it is on a keyboard (['qwertyuiop', 'asdfghjkl', 'zxcvbnm']).
αyPushes all the vowels including y (AEIOUYaeiouy).
απPushes pi (3.1415926...).
αφPushes phi/the golden ratio (1.6180339...).
αΓPushes an ASCII goat. (Don't ask.)
αΩPushes the Ohm codepage.

Time (υ)

ComponentActionDescription
υ!N/APushes the current timestamp.
υ%Pop aPushes the current time formatted using a as a strftime format string.
υDN/APushes the current day.
υHN/APushes the current hour.
υIN/APushes the current minute.
υMN/APushes the current month.
υNN/APushes the current nanosecond (yes, really).
υSN/APushes the current second.
υWN/APushes the current weekday (0-6).
υYN/APushes the current year.
υdPop aPushes the day specified by timestamp a (UTC).
υhPop aPushes the hour specified by timestamp a (UTC).
υiPop aPushes the minute specified by timestamp a (UTC).
υmPop aPushes the month specified by timestamp a (UTC).
υnPop aPushes the nanosecond specified by timestamp a (UTC).
υsPop aPushes the second specified by timestamp a (UTC).
υwPop aPushes the weekday (0-6) specified by timestamp a (UTC).
υyPop aPushes the year specified by timestamp a (UTC).
υ‰Pop a, bPushes the time specified by timestamp a formatted using b as a strftime format string.
υ§Pop a, bPushes the timestamp of the time given by parsing a, using b as a strptime format string.

Arithmetic (Æ)

ComponentActionDescription
ƲPop aPushes whether a is a perfect square.
ÆⁿPop a, bPushes whether a is a perfect bth power.
Æ↑Pop a, bPushes the greatest common divisor of a and b.
Æ↓Pop a, bPushes the least common multiple of a and b.
Æ×Pop a, bPushes ab (complex exponentiation), where a and b are either real or complex numbers.
Æ*Pop a, bPushes a * b (complex multiplication), where a and b are either real or complex numbers.
Æ/Pop a, bPushes a / b (complex division), where a and b are either real or complex numbers.
ÆCPop aPushes the cosine of a radians.
ÆDPop aPushes a radians converted to degrees.
ÆEPop aPushes a degrees converted to radians.
ÆHPop a, bPushes the hypotenuse of a right triangle with sides a and b.
ÆLPop aPushes the natural logarithm of a.
ÆMPop aPushes the base 10 logarithm of a.
ÆNPop aPushes the base 2 logarithm of a.
ÆRPop aPushes the roots of a (as a list of complex numbers), where a is an array containing polynomial coefficients (i.e. [1, 1, 1] => [[-0.5, 0.866], [-0.5, -0.866]]).
ÆSPop aPushes the sine of a radians.
ÆTPop aPushes the tangent of a radians.
ÆcPop aPushes the arccosine of a.
ÆlPop a, bPushes the base a logarithm of b.
ÆmPop aPushes the arithmetic mean of a.
ÆnPop aPushes the arithmetic median of a.
ÆoPop aPushes the arithmetic mode of a.
ÆpPop a, bPushes whether a and b are coprime.
ÆrPop aPushes the coefficients (as a list of complex numbers) of the polynomial with roots a (also a list of complex numbers) (i.e. [[-0.5, 0.866], [-0.5, -0.866]] => [[1, 0], [1, 0], [1, 0]] (approximately)).
ÆsPop aPushes the arcsine of a.
ÆtPop aPushes the arctangent of a.
ÆuPop a, bPushes atan2(b, a).
ÆρPop a, bPushes the polynomial resulting from the multiplication of polynomials a and b, where a, b, and the result are all lists of real numbers representing coefficients.
ƬPop aPushes the complex square root of a, where a is either a number or an array in the form [real, imag].
ƤPop a, bPushes the bth a-gonal number.
ƫPop a, bPushes a << b (left bit-shift).
ƻPop a, bPushes a >> b (right bit-shift).

Extras (·)

ComponentActionDescription
·¹Pop aPushes the MD5 hash of a.
·²Pop aPushes the SHA1 hash of a.
·³Pop aPushes the SHA256 hash of a.
·⁴Pop aPushes the SHA512 hash of a.
·/Pop a, bPushes an array of the matched string + captures of a tested against regex b.
·\Pop aPushes the diagonals of a, assuming a is a matrix.
·GPop aPerforms a GET request to a and pushes the response body.
·cPop aPushes a compressed using Ohm's custom string compression.
·dPop aPushes a decompressed using Ohm's custom string compression.
·ePop aEvaluates a as Ohm code.
·pPop aPushes all prefixes of a.
·rN/APushes a random float between 0 and 1.
·sPop aPushes all suffixes of a.
·wPop a, bPushes the index where the subarray b occurs in a.
·~Pop a, bIf a matches regex b, pushes the index of the first match, else pushes -1.
·ψPop a, bPushes whether a and b are permutations of each other.
·ΘPop a, blockContinuously evaluates the given block until the result returned has already been seen, using a as the initial value. Pushes the final result.
·ΩPop a, blockSame as above, except pushes the list of intermediate results.
·ØPop aPushes the indices of a grouped together by equal values.
·¦Pop a, bPushes a rounded to b decimal places.