-
Notifications
You must be signed in to change notification settings - Fork 6
Commands
Raghu Ranganathan edited this page Jun 23, 2021
·
80 revisions
This page documents the currently implemented commands of Husk in the order that they appear on the codepage.
For those unfamiliar with the Haskell-style type description, the descriptions are formatted as (funcArg1) -> (funcArg2) -> ... arg1 -> arg2 -> ... -> output
Char | Alias | Name | Type | Description |
---|---|---|---|---|
¤ |
cur |
combin |
(y -> y -> z) -> (x -> y) -> x -> x -> z |
Compose both arguments of binary function |
½ |
hlf |
halve |
TNum -> TNum |
Divide by 2 (does not floor) |
islowr |
TChar -> TNum |
Is it a lowercase letter (returns codepoint or 0) | ||
halfL |
[x] -> [[x]] |
Split a list into two halves. If the length is odd, the first half will be longer. | ||
↕ |
ud |
span |
(Concrete y) => (x -> y) -> [x] -> ([x], [x]) |
Split at first value where function gives falsy result |
↑ |
up |
take |
TNum -> [x] -> [x] |
Take n elements from list. Negative n takes from the end |
take2 |
[x] -> TNum -> [x] |
Flipped version of take
|
||
takew |
(Concrete y) => (x -> y) -> [x] -> [x] |
Longest prefix where function gives truthy result on each individual element | ||
↓ |
dow |
drop |
TNum -> [x] -> [x] |
Drop n elements from list. Negative n drops from the end |
drop2 |
[x] -> TNum -> [x] |
Flipped version of drop
|
||
dropw |
(Concrete y) => (x -> y) -> [x] -> [x] |
Drop longest prefix where function gives truthy result on each individual element | ||
↔ |
lr |
swap |
(x, y) -> (y, x) |
Swap a pair |
rev |
[x] -> [x] |
Reverse a list | ||
revnum |
TNum -> TNum |
Reverse the digits of a number | ||
← |
lft |
head |
[x] -> x |
First value of a list |
fst |
(x, y) -> x |
Left value of a pair | ||
predN |
TNum -> TNum |
Decrement number | ||
predC |
TChar -> TChar |
Decrement character | ||
→ |
rgt |
last |
[x] -> x |
Last value of a list |
snd |
(x, y) -> y |
Right value of a pair | ||
succN |
TNum -> TNum |
Increment number | ||
succC |
TChar -> TChar |
Increment character | ||
\n |
Newline | Separates lines in program | ||
¦ |
bar |
divds |
TNum -> TNum -> TNum |
1 if b == 0, b / a if a divides b, 0 otherwise |
subset |
Concrete x => [x] -> [x] -> TNum |
Is the second argument a subset of the first (counting multiplicities but not order) | ||
¡ |
exc |
iter |
(x -> x) -> x -> [x] |
Apply function repeatedly, collect values in infinite list |
iterP |
([x] -> x) -> [x] -> [x] |
Apply function repeatedly, obtaining a new value from the list of previous ones | ||
iterL |
(x -> [x]) -> [x] -> [x] |
Apply function repeatedly, concatenate results into infinite list | ||
iter2 |
(x -> (x, y)) -> x -> [y] |
Apply function repeatedly to first result, collect second results into infinite list | ||
‼ |
dex |
twice |
(x -> x) -> (x -> x) |
Apply function twice |
… |
ell |
rangeN |
TNum -> TNum -> [TNum] |
Inclusive numeric range |
rangeC |
TChar -> TChar -> [TChar] |
Inclusive character range | ||
rangeL |
[TNum] -> [TNum] |
Fill gaps with numeric ranges | ||
rangeS |
[TChar] -> [TChar] |
Fill gaps with character ranges | ||
‰ |
ppm |
divmod |
TNum -> TNum -> [TNum] |
Two-element list [b ÷ a, b % a] |
† |
dag |
vec |
(Vect a b x y) => (a -> b) -> x -> y |
Vectorize a function ("deep map") |
‡ |
ddg |
vec2 |
(Vect2 a b c x y z) => (a -> b -> c) -> x -> y -> z |
Bi-vectorize a function ("deep zip") |
√ |
srd |
sqrt |
TNum -> TNum |
Square root |
isalph |
TChar -> TNum |
Is it a letter (returns codepoint or 0) | ||
≤ |
leq |
le |
(Concrete x) => x -> x -> TNum |
Less than or equal |
≥ |
geq |
ge |
(Concrete x) => x -> x -> TNum |
Greater than or equal |
± |
pm |
sign |
TNum -> TNum |
Sign of a number |
isdigt |
TChar -> TNum |
Is it a digit (returns codepoint or 0) | ||
∂ |
ptl |
adiags |
[[x]] -> [[x]] |
Antidiagonals |
∫ |
int |
cumsum |
[TNum] -> [TNum] |
Cumulative sum |
cumcat |
[[a]] -> [[a]] |
Cumulative concatenation | ||
∞ |
inf |
rep |
x -> [x] |
Infinite list of copies of the argument |
≈ |
apx |
simil |
(Concrete x) => x -> x -> TNum |
Similar. For numbers or chars checks if the absolute difference is <=1. For lists checks if they are the same length. For Pairs checks if both elements are similar. |
≠ |
neq |
neq |
(Concrete x) => x -> x -> TNum |
Not equal |
≡ |
cng |
congr |
(Concrete x) => x -> x -> TNum |
Recursively check if the two arguments have the same shape and the same distribution of truthy/falsy values. Returns 1 or 0. |
¬ |
neg |
not |
(Concrete x) => x -> TNum |
Negation of truthiness |
÷ |
div |
idiv |
TNum -> TNum -> TNum |
Integer division |
× |
eks |
mix |
(x -> y -> z) -> [x] -> [y] -> [z] |
Function applied to all pairs drawn from the lists |
|
Space | Token separator, flag for multi-digit labels and marked lines | ||
! |
index |
TNum -> [x] -> x |
Value at modular index | |
index2 |
[x] -> TNum -> x |
index with flipped arguments |
||
idx2d |
(TNum,Tnum) -> [[x]] -> x |
Value at modular 2D index | ||
idx2d2 |
[[x]] -> (TNum,TNum) -> x |
idx2d with flipped arguments |
||
\ |
inv |
TNum -> TNum |
Reciprocal number | |
swcase |
TChar -> TChar |
Swap case | ||
" |
Double quote | String delimiter | ||
# |
countf |
(Concrete y) => (x -> y) -> [x] -> TNum |
Number of list elems where function result is truthy | |
count |
(Concrete x) => x -> [x] -> TNum |
Number of occurrences of value in list | ||
count' |
(Concrete x) => [x] -> x -> TNum |
Flipped version of count
|
||
count2 |
(Concrete y) => (x -> x -> y) -> [x] -> TNum |
Number of adjacent pairs of elements where function result is truthy | ||
% |
mod |
TNum -> TNum -> TNum |
Modulus of second argument by first | |
& |
and |
(Concrete x) => x -> x -> x |
Second argument if falsy, else first | |
and' |
(Concrete x, Concrete y) => x -> y -> TNum |
Are both arguments truthy? | ||
' |
Single quote | Character delimiter | ||
() |
Parentheses | Group expressions | ||
* |
mul |
TNum -> TNum -> TNum |
Multiply numbers | |
replen |
[x] -> TNum -> [x] |
Repeat list to multiply its length by n; negative n also reverses the list | ||
repln' |
TNum -> [x] -> [x] |
replen with flipped arguments |
||
cart2 |
[x] -> [x] -> [[x]] |
Cartesian product with 2-element lists | ||
ccons |
[x] -> [[x]] -> [[x]] |
Cartesian product with cons
|
||
csnoc |
[[x]] -> [x] -> [[x]] |
Cartesian product with snoc
|
||
+ |
add |
TNum -> TNum -> TNum |
Add numbers | |
cat |
[x] -> [x] -> [x] |
Concatenate lists | ||
, |
pair |
x -> y -> (x, y) |
Construct pair | |
- |
sub |
TNum -> TNum -> TNum |
Subtract first argument from second | |
diffl |
(Concrete x) => [x] -> [x] -> [x] |
List difference | ||
del |
(Concrete x) => x -> [x] -> [x] |
Remove first occurrence of element from list | ||
. |
Decimal point | Used in floating point literals | ||
/ |
div |
TNum -> TNum -> TNum |
Exact division, uses rational numbers when possible | |
0 -9
|
Digits | Used in numeric literals | ||
: |
cons |
x -> [x] -> [x] |
Prepend a value to a list | |
snoc |
[x] -> x -> [x] |
Append a value to a list | ||
; |
pure |
x -> [x] |
Create singleton list | |
< |
lt |
(Concrete x) => x -> x -> TNum |
Less than | |
= |
eq |
(Concrete x) => x -> x -> TNum |
Equals | |
> |
gt |
(Concrete x) => x -> x -> TNum |
Greater than | |
? |
if |
(Concrete x) => y -> y -> x -> y |
Ternary if conditioned on third argument | |
if2 |
(Concrete x) => (x -> y) -> y -> x -> y |
If truthy, apply function, else give default value | ||
fif |
(Concrete x) => (z -> y) -> (z -> y) -> (z -> x) -> z -> y |
Ternary if for functions | ||
A |
mean |
[TNum] -> TNum |
Average of a list | |
B |
base |
TNum -> TNum -> [TNum] |
Digits in given base | |
abase |
TNum -> [TNum] -> TNum |
Interpret as digits in given base | ||
C |
cut |
TNum -> [a] -> [[a]] |
Cut into sublists of given length. Negative n counts lengths from the end. | |
cut2 |
[a] -> TNum -> [[a]] |
Flipped version of cut
|
||
cuts |
[TNum] -> [a] -> [[a]] |
Cut off substrings of given lengths. Negative n cuts from the end. | ||
cutL |
[[b]] -> [a] -> [[a]] |
Cut into same lengths as the lists in first input. | ||
D |
double |
TNum -> TNum |
Multiply by 2 | |
isuppr |
TChar -> TNum |
Is it an uppercase letter (returns codepoint or 0) | ||
doubL |
[x]->[x] |
Repeats a list twice | ||
E |
same |
Concrete x => [x] -> TNum |
Length plus 1 if all elements are equal, else 0 | |
F |
foldl |
(y -> x -> y) -> y -> [x] -> y |
Left fold | |
foldl1 |
(x -> x -> x) -> [x] -> x |
Left fold without initial value | ||
aptp |
(x -> y -> z) -> (x, y) -> z |
Apply binary function to tuple | ||
G |
scanl |
(y -> x -> y) -> y -> [x] -> [y] |
Scan from left | |
scanl1 |
(x -> x -> x) -> [x] -> [x] |
Scan from left without initial value | ||
scltp |
(x -> y -> z) -> (x, y) -> (z, y) |
Apply binary function to tuple, updating left element | ||
I |
id |
x -> x |
Identity function | |
J |
join |
[x] -> [[x]] -> [x] |
Join by a list | |
join' |
x -> [[x]] -> [x] |
Join by an element | ||
joinE |
[x] -> [x] -> [x] |
Join elements by a list | ||
joinV |
x -> [x] -> [x] |
Insert value between all elements | ||
K |
const |
x -> y -> x |
Constant function | |
L |
len |
[x] -> TNum |
Length of list | |
nlen |
TNum -> TNum |
Length of string representation | ||
M |
lmap |
(x -> y -> z) -> [x] -> y -> [z] |
Map over left argument | |
lmaptp |
(x -> z) -> (x, y) -> (z, y) |
Apply function to left element of tuple | ||
N |
nats |
[TNum] |
Infinite list of natural numbers | |
O |
sort |
(Concrete x) => [x] -> [x] |
Sort list in ascending order | |
P |
perms |
[a] -> [[a]] |
List of all permutations of the given list | |
Q |
slices |
[a] -> [[a]] |
All contiguous sublists | |
R |
replic |
TInt -> a -> [a] |
List composed by a given number of copies of a value | |
replif |
a -> TInt -> [a] |
replic with flipped arguments |
||
S |
hook |
(x -> y -> z) -> (x -> y) -> x -> z |
S-combinator | |
bhook |
(x -> y -> z) -> (x -> u -> y) -> x -> u -> z |
S-combinator with extra argument: S f g a b means f a (g a b)
|
||
T |
trsp |
[[a]] -> [[a]] |
Transpose a 2-d list, elements missing from shorter rows are skipped | |
trspw |
a -> [[a]] -> [[a]] |
Transpose using the given element to pad shorter rows | ||
unzip |
[(a, b)] -> ([a], [b]) |
Unzip a list of pairs | ||
U |
nubw |
Concrete a => [a] -> [a] |
Longest prefix of a list with all unique elements | |
nubwN |
Concrete a => TNum -> [a] -> [a] |
Longest prefix with unique subslists of length abs(n). For negative n, remove all elements of first repeated sublist. | ||
V |
any |
Concrete b => (a->b) -> [a] -> TNum |
Index of first element satisfying predicate, 0 if not found | |
any2 |
Concrete b => (a->a->b) -> [a] -> TNum |
Index of first element satisfying the predicate in respect to the next element in the list, 0 if not found | ||
W |
where |
Concrete b => (a->b) -> [a] -> [TNum] |
Indices of elements satisfying predicate | |
where2 |
Concrete b => (a->a->b) -> [a] -> [TNum] |
Indices of elements satisfying the predicate in respect to the next element in the list | ||
X |
slice |
TNum -> [a] -> [[a]] |
All subslists of length n. Negative n includes final stubs. | |
Y |
max |
(Concrete x) => x -> x -> x |
Maximum of two values | |
^ |
power |
TNum -> TNum -> TNum |
Second argument raised to the power of the first | |
_ |
neg |
TNum -> TNum |
Negate a number | |
tolowr |
TChar -> TChar |
Covert to lowercase | ||
` |
flip |
(x -> y -> z) -> y -> x -> z |
Invert order of arguments | |
a |
abs |
TNum -> TNum |
Absolute value | |
touppr |
TChar -> TChar |
Convert to uppercase | ||
c |
chr |
TNum -> TChar |
Convert integer to character | |
ord |
TChar -> TNum |
Convert character to integer | ||
d |
base10 |
TNum -> [TNum] |
Base-10 digits | |
abas10 |
[TNum] -> TNum |
Interpret in base 10 | ||
e |
list2 |
x -> x -> [x] |
Create a list with two elements | |
f |
filter |
(Concrete y) => (x -> y) -> [x] -> [x] |
Filter list by predicate | |
select |
(Concrete x) => [x] -> [y] -> [y] |
Filter list by another list | ||
g |
group |
(Concrete x) => [x] -> [[x]] |
Group equal adjacent values | |
h |
init |
[x] -> [x] |
Remove last element | |
i |
d2i |
TDouble -> TNum |
Convert from Double to Int by rounding (round half to even) | |
c2i |
TChar -> TNum |
Chars in "0123456789" return their digit value, other Chars return 0 | ||
s21 |
[TChar] -> TNum |
Return the first integer found inside the string | ||
k |
keyon |
Concrete y => (x -> y) -> [x] -> [[x]] |
Group list elements into classes by function value. Classes are ordered by the function values. | |
keyby |
Concrete y => (x -> x -> y) -> [x] -> [[x]] |
Group list elements into classes by equality predicate. Classes are ordered by occurrence. | ||
m |
map |
(x -> y) -> [x] -> [y] |
Map function over list | |
mapr |
[x -> y] -> x -> [y] |
Map list of functions over value | ||
maptp |
(x -> y) -> (x, x) -> (y, y) |
Map function over tuple | ||
n |
bwand |
TNum -> TNum -> TNum |
Bitwise AND | |
isect |
Concrete x => [x] -> [x] -> [x] |
List intersection, counting multiplicities | ||
o |
com |
(y -> z) -> (x -> y) -> x -> z |
Function composition | |
com2 |
(z -> u) -> (x -> y -> z) -> x -> y -> u |
Binary composition | ||
com3 |
(u -> v) -> (x -> y -> z -> u) -> x -> y -> z -> v |
Ternary composition | ||
com4 |
(v -> w) -> (x -> y -> z -> u -> v) -> x -> y -> z -> u -> w |
Quaternary composition | ||
p |
pfac |
TNum -> [TNum] |
Prime factorization | |
r |
read |
(Concrete x) => [TChar] -> x |
Convert string to value | |
s |
show |
(Concrete x) => x -> [TChar] |
Convert value to string | |
t |
tail |
[x] -> [x] |
Remove first element | |
u |
nub |
(Concrete x) => [x] -> [x] |
Remove duplicates | |
v |
bwor |
TNum -> TNum -> TNum |
Bitwise OR | |
union |
Concrete x => [x] -> [x] -> [x] |
List union: concatenate, removing duplicates from first argument | ||
ucons |
Concrete x => x -> [x] -> [x] |
Prepend unless already present | ||
usnoc |
Concrete x => [x] -> x -> [x] |
Append unless already present | ||
w |
words |
[TChar] -> [[TChar]] |
Split on spaces | |
unwords |
[[TChar]] -> [TChar] |
Join with spaces | ||
uwshow |
Concrete x => [x] -> [TChar] |
Join string representations with spaces | ||
uwpshw |
(Concrete x, Concrete y) => (x, y) -> [TChar] |
Join string representations with space | ||
x |
split |
Concrete x => x -> [x] -> [[x]] |
Split on given element | |
split' |
Concrete x => [x] -> x -> [[x]] |
Flipped version of split
|
||
splitL |
Concrete x => [x] -> [x] -> [[x]] |
Split on occurrences of sublist | ||
y |
min |
(Concrete x) => x -> x -> x |
Minimum of two values | |
z |
zip |
(x -> y -> z) -> [x] -> [y] -> [z] |
Zip lists with function | |
| |
or |
(Concrete x) => x -> x -> x |
Second argument if truthy, else first | |
or' |
(Concrete x, Concrete y) => x -> y -> TNum |
Is any of the arguments truthy? | ||
~ |
branch |
(x -> y -> z) -> (u -> x) -> (v -> y) -> (u -> v -> z) |
Compose both arguments of binary function separately | |
· |
blt |
comf |
(x -> y -> z) -> (u -> y) -> (x -> u -> z) |
Compose second argument of function |
comf2 |
(x -> y -> z) -> (u -> v -> y) -> (x -> u -> v -> z) |
Compose second argument of function with binary function | ||
comf3 |
(x -> y -> z) -> (u -> v -> w -> y) -> (x -> u -> v -> w -> z) |
Compose second argument of function with ternary function | ||
comf4 |
(x -> y -> z) -> (u -> v -> w -> t -> y) -> (x -> u -> v -> w -> t -> z) |
Compose second argument of function with quaternary function | ||
₀ -₉
|
nul -nin
|
Subscript digits | Line labels | |
⌈ |
lce |
ceil |
TNum -> TNum |
Ceiling function |
⌉ |
rce |
lcm |
TNum -> TNum -> TNum |
Lowest common multiple |
⌊ |
lfl |
floor |
TNum -> TNum |
Floor function |
⌋ |
rfl |
gcd |
TNum -> TNum -> TNum |
Greatest common divisor |
Γ |
Gam |
list |
y -> (x -> [x] -> y) -> [x] -> y |
Pattern match on list |
listN |
(x -> [x] -> y) -> [x] -> y |
Pattern match on nonempty list | ||
listF |
y -> (([x] -> y) -> (x -> [x] -> y)) -> [x] -> y |
Recursive pattern match on list | ||
listNF |
(([x] -> y) -> (x -> [x] -> y)) -> [x] -> y |
Recursive pattern match on nonempty list | ||
Θ |
The |
prep0 |
[x]->[x] |
Prepends a default value of the appropriate type to a list. Default values are either falsy values (0,[],...) or functions returning those values. |
Λ |
Lam |
all |
Concrete b => (a->b) -> [a] -> TNum |
Length + 1 if all elements satisfy predicate, else 0 |
all2 |
Concrete b => (a->a->b) -> [a] -> TNum |
Length + 1 if all adjacent pairs of elements satisfy the predicate, else 0 | ||
Ξ |
Xi |
merge |
Concrete a => [[a]] -> [a] |
Merge a list of lists. Each list should be ordered, and if there are more than 2 lists, their heads should also be ordered. Works on infinite lists. |
merge2 |
Concrete b => (a -> b) -> [[a]] -> [a] |
Like merge , but preserves order obtained by applying f to each value. |
||
Π |
Pi |
prod |
[TNum] -> TNum |
Product of list |
fact |
TNum -> TNum |
Factorial | ||
cartes |
[[x]] -> [[x]] |
Cartesian product | ||
Σ |
Sig |
sum |
[TNum] -> TNum |
Sum of list |
chrsum |
[Chr] -> TNum |
Sum of code points | ||
trianI |
TNum -> TNum |
Triangular number | ||
concat |
[[x]] -> [x] |
Concatenate lists | ||
Ψ |
Psi |
toadjM |
(((a, a) -> c) -> [(a,a)] -> [[(a, a)]]) -> (a -> a -> c) -> [a] -> [[a]] |
Apply higher-order function on adjacent pairs instead of single elements |
toadjL |
(((a, a) -> c) -> [(a,a)] -> [(a, a)]) -> (a -> a -> c) -> [a] -> [a] |
Like toadjL but result is a flat list |
||
toadjV |
(((a, a) -> c) -> [(a,a)] -> (a, a)) -> (a -> a -> c) -> [a] -> a |
Like toadjL but result is an element |
||
toadjN |
(((a, a) -> c) -> [(a,a)] -> b) -> (a -> a -> c) -> [a] -> b |
Like toadjL but result is any value |
||
Ω |
Ohm |
until |
Concrete y => (x -> y) -> (x -> x) -> x -> x |
Iterate function until test result is truthy |
δ |
del |
decorM |
(((a, b) -> c) -> [(a,b)] -> [[(a,d)]]) -> (a -> b -> c) -> [a] -> [b] -> [[d]] |
Apply higher-order function using auxiliary list |
decorL |
(((a, b) -> c) -> [(a,b)] -> [(a,d)]) -> (a -> b -> c) -> [a] -> [b] -> [d] |
Like decorM but result is a flat list |
||
decorV |
(((a, b) -> c) -> [(a,b)] -> (a,d)) -> (a -> b -> c) -> [a] -> [b] -> d |
Like decorM but result is an element |
||
decorN |
(((a, b) -> c) -> [(a,b)] -> d) -> (a -> b -> c) -> [a] -> [b] -> d |
Like decorM but result is any value |
||
ε |
eps |
small |
TNum -> TNum |
Has absolute value at most 1 |
single |
[x] -> TNum |
Has length 1 | ||
η |
eta |
onixes |
((TNum -> a) -> [TNum] -> b) -> [a] -> b |
Act on list of indices using indexing function. If α is a function, ηα is roughly equivalent to α§!ŀ . |
λ |
lam |
Small lambda | One-argument anonymous function | |
μ |
mu |
Small mu | Two-argument anonymous function | |
ξ |
xi |
Small xi | Three-argument anonymous function | |
π |
pi |
cpow |
TNum -> [x] -> [[x]] |
Cartesian power |
cpow' |
[x] -> TNum -> [[x]] |
Flipped version of cpow
|
||
cpowN |
TNum -> TNum -> [[TNum]] |
Cartesian power of range [1..n] | ||
σ |
sjg |
subs |
(Concrete x) => x -> x -> [x] -> [x] |
Substitute all occurrences of an element. |
subs2 |
(Concrete x) => [x] -> [x] -> [x] -> [x] |
Substitute all occurrences of a contiguous sublist. | ||
φ |
phi |
Small phi | Self-referential anonymous function | |
χ |
chi |
Small chi | Self-referential anonymous function with 2 extra arguments | |
ψ |
psi |
Small psi | Self-referential anonymous function with extra argument | |
ω |
ohm |
fixp |
(Concrete x) => (x -> x) -> x -> x |
Find periodic (usually fixed) point by iterating |
fixpL |
(Concrete x) => (x -> [x]) -> x -> [x] |
Find periodic (usually fixed) point under map-and-concatenate | ||
⁰ -⁹
|
Nul -Nin
|
Superscript digits | Lambda arguments | |
¢ |
cnt |
cycle |
[x] -> [x] |
Repeat list infinitely |
£ |
gbp |
oelem |
(Concrete x) => [x] -> x -> TNum |
Like elem , but the list is supposed to be sorted |
oelem' |
(Concrete x) => x -> [x] -> TNum |
oelem with flipped arguments |
||
€ |
eur |
elem |
(Concrete x) => [x] -> x -> TNum |
Index of first occurrence, or 0 if not found |
elem' |
(Concrete x) => x -> [x] -> TNum |
elem with flipped arguments |
||
subl |
(Concrete x) => [x] -> [x] -> TNum |
Index of first beginning of the sublist, or 0 if not found | ||
¥ |
yen |
ixsof |
(Concrete x) => x -> [x] -> [TNum] |
Indices of occurrence |
ixsof2 |
(Concrete x) => [x] -> x -> [TNum] |
Flipped version of ixsof
|
||
ƒ |
fl |
fix |
(x -> x) -> x |
Least fixed point (used for recursion) |
´ |
acu |
argdup |
(x -> x -> y) -> x -> y |
Apply twice to same argument |
▲ |
top |
maxl |
(Concrete x) => [x] -> x |
Maximum of list |
▼ |
bot |
minl |
(Concrete x) => [x] -> x |
Minimum of list |
► |
est |
maxlby |
Concrete y => (x -> x -> y) -> [x] -> x |
Maximum element with custom ordering predicate |
maxlon |
Concrete y => (x -> y) -> [x] -> x |
Element that maximizes function result | ||
◄ |
wst |
minlby |
Concrete y => (x -> x -> y) -> [x] -> x |
Minimum element with custom ordering predicate |
minlon |
Concrete y => (x -> y) -> [x] -> x |
Element that minimizes function result | ||
§ |
sec |
fork |
(x -> y -> z) -> (u -> x) -> (u -> y) -> u -> z |
Compose each argument of binary function |
fork2 |
(x -> y -> z) -> (u -> v -> x) -> (u -> v -> y) -> u -> v -> z |
Compose each argument of binary function with binary function | ||
Ċ |
dC |
gaps |
TNum -> [a] -> [a] |
Take every abs(n)'th element, starting from the first if n is positive, from the -n-1st if negative |
gaps2 |
[a] -> TNum -> [a] |
Flipped version of gaps
|
||
gapsL |
[TNum] -> [a] -> [a] |
Like gaps , but specifying the length of each jump |
||
Ḋ |
dD |
divs |
TNum -> [TNum] |
List of divisors |
Ḟ |
dF |
foldr |
(x -> y -> y) -> y -> [x] -> y |
Right fold |
foldr1 |
(x -> x -> x) -> [x] -> x |
Right fold without initial value | ||
apftp |
(y -> x -> z) -> (x, y) -> z |
Apply flipped function to tuple | ||
Ġ |
dG |
scanr |
(x -> y -> y) -> y -> [x] -> [y] |
Scan from right |
scanr1 |
(x -> x -> x) -> [x] -> [x] |
Scan from right without initial value | ||
scrtp |
(x -> y -> z) -> (x, y) -> (x, z) |
Apply binary function to tuple, updating right element | ||
İ |
dI |
Dotted capital I | Access built-in numeric sequences | |
Ṁ |
dM |
rmap |
(x -> y -> z) -> x -> [y] -> [z] |
Map over right argument |
rmaptp |
(y -> z) -> (x, y) -> (x, z) |
Apply function to right element | ||
Ṗ |
dP |
powset |
[x] -> [[x]] |
All finite subsequences |
powstN |
TNum -> [x] -> [[x]] |
Subsequences of length n. Negative n gives subsequences of length up to -n. | ||
Ṙ |
dR |
clone |
TNum -> [x] -> [x] |
Replicate each element by given number |
clone' |
[x] -> TNum -> [x] |
clone with flipped arguments |
||
clones |
[TNum] -> [x] -> [x] |
Replicate each element by corresponding number | ||
Ṡ |
dS |
hookf |
(x -> y -> z) -> (y -> x) -> y -> z |
Like S , but composes on other argument |
bhookf |
(x -> y -> z) -> (u -> y -> x) -> u -> y -> z |
Like binary S , but composes on other argument: Ṡ f g a b means f (g a b) b
|
||
Ṫ |
dT |
table |
(x -> y -> z) -> [x] -> [y] -> [[z]] |
Outer product, or "multiplication table" |
Ẋ |
dX |
mapad2 |
(x -> x -> y) -> [x] -> [y] |
Map over pairs of adjacent values |
mapad3 |
(x -> x -> x -> y) -> [x] -> [y] |
Map over triples of adjacent values | ||
ḋ |
dd |
base2 |
TNum -> [TNum] |
Binary digits |
abase2 |
[TNum] -> TNum |
Interpret in base 2 | ||
ė |
de |
list3 |
x -> x -> x -> [x] |
Create a list with three elements |
ḟ |
df |
find |
(Concrete y) => (x -> y) -> [x] -> x |
Return first value that gives truthy result |
findN |
(Concrete x) => (TNum -> x) -> TNum -> TNum |
Return first number at least n that gives truthy result | ||
ġ |
dg |
groupOn |
(Concrete y) => (x -> y) -> [x] -> [[x]] |
Group on function result |
groupBy |
(Concrete y) => (x -> x -> y) -> [x] -> [[x]] |
Group by equality predicate | ||
ḣ |
dh |
heads |
(Concrete x) => x -> [x] |
Prefixes for lists, range for numbers |
ŀ |
dl |
lrange |
TNum -> [TNum] |
Lowered range (from 0 to n-1) |
ixes |
[x] -> [TNum] |
The range [1 .. length(x)] | ||
ṁ |
dm |
cmap |
(x -> [y]) -> [x] -> [y] |
Map function over list and concat the result |
smap |
(x -> TNum) -> [x] -> TNum |
Map function over list and sum the result | ||
cmapr |
[x -> [y]] -> x -> [y] |
Map list of functions over value and concat the result | ||
smapr |
[x -> TNum] -> x -> TNum |
Map list of functions over value and sum the result | ||
ȯ |
do |
Too many to list | Composition of three functions; ȯABC is roughly equivalent to oAoBC
|
|
ṗ |
dp |
isprime |
TNum -> TNum |
Return the index of the argument in the list of all primes, or 0 if it is not a prime number |
ṙ |
dr |
rotate |
TNum -> [a] -> [a] |
Rotate n steps to the left |
rotatf |
[a] -> TNum -> [a] |
rotate with flipped arguments |
||
ṡ |
ds |
srange |
TNum -> [TNum] |
Symmetric range (from -n to n) |
rvixes |
[x] -> [TNum] |
ixes reversed |
||
ṫ |
dt |
tails |
(Concrete x) => x -> [x] |
Suffixes for lists, reversed range for numbers |
ż |
dz |
zip' |
(a -> a -> a) -> [a] -> [a] -> [a] |
Like zip, but keeps trailing elements from the longer list unchanged. |
¨ |
die |
Dieresis | Delimiter for compressed strings | |
Ë |
DE |
sameon |
Concrete y => (x -> y) -> [x] -> TNum |
Are function results all equal? Returns length + 1 or 0. |
sameby |
Concrete y => (x -> x -> y) -> [x] -> TNum |
Are all values equal by a predicate? Checks p x y for all pairs x, y that occur in this order. Returns length + 1 or 0. |
||
Ö |
DO |
sorton |
(Concrete y) => (x -> y) -> [x] -> [x] |
Sort by function result |
sortby |
(Concrete y) => (x -> x -> y) -> [x] -> [x] |
Sort using ordering predicate. In Ö p , p x y is interpreted as "x is greater than y ". |
||
ë |
De |
list4 |
x -> x -> x -> x -> [x] |
Create a list with four elements |
ö |
Do |
Too many to list | Composition of four functions; öABCD is roughly equivalent to oAoBoCD
|
|
ü |
Du |
nubon |
(Concrete x) => (x -> y) -> [x] -> [x] |
Remove duplicates by function result |
nubby |
(Concrete x) => (x -> x -> y) -> [x] -> [x] |
Remove duplicates using equality predicate | ||
ø |
so |
empty |
[x] |
Empty list |
□ |
squ |
square |
TNum -> TNum |
Raise to second power |
isanum |
TChar -> TNum |
Is it alphanumeric (returns codepoint or 0) | ||
¶ |
pgf |
lines |
[TChar] -> [[TChar]] |
Split on newlines |
unlines |
[[TChar]] -> [TChar] |
Join by newlines | ||
ulshow |
Concrete x => [x] -> [TChar] |
Join string representations by newlines | ||
ulpshw |
(Concrete x, Concrete y) => (x, y) -> [TChar] |
Join string representations with newline | ||
« |
ll |
mapacL |
(x -> y -> x) -> (x -> y -> z) -> x -> [y] -> [z] |
Scanl over a list with the first function, but results are produced by applying the second function to intermediate steps |
» |
rr |
mapacR |
(y -> x -> x) -> (y -> x -> z) -> x -> [y] -> [z] |
Scanr over a list with the first function, but results are produced by applying the second function to intermediate steps |
This is the list of functions applied to overflowing line labels:
| argdup
| flip
| map
| zip
| hook
|