pip
pip copied to clipboard
Ideas for new operators
This issue is a place to brainstorm potentially useful new operators. Most of these, if they are implemented, will become 2-uppercase-letter operators; some will be 2-byte symbolic operators. Feel free to make suggestions in the comments. Also, if you see an idea you like, feel free to implement it and make a pull request!
- [x] Chop: split an iterable into n chunks of (roughly) equal size; unary version splits into two chunks (
CH
, or possibly><
because it's the converse of<>
) - [x] Flatten List (
FL
for flattening one level,FA
for FlattenAll) - [x] Map and flatten (
MF
) - [x] Filter-enumerate: filters an iterable, but the first argument to the function is the index of the element and the second is the element itself (
FE
) - [x] Filter-unpack: filters an iterable, but the arguments to the function are the elements of each element rather than the element itself (
FU
) - [x] Filter negated: keeps elements for which the function returns a falsey value (
FN
) - [x] Filter and join (
FJ
) - [ ] Filter and flatten (
FF
) - [x] Filter indexes: like
FE
, but returns a list of indexes instead of a list of elements (FX
) - [ ] Take-while and drop-while (
TW
andDW
) - [ ] Fold on function (
FO
for [left] Fold,FR
for FoldRight) - [ ] Iterate function (
IW
for Iterate While truthy,IU
for Iterate Until truthy,IQ
for Iterate while uniQue) - [ ] Pad with spaces (
LS
for LeftSpace,RS
for RightSpace,BS
for BothSpace; orPL
for PadLeft,PR
for PadRight,PC
for PadCentered) - [ ] Left-pad with zeros (
LZ
for LeftZero; orZP
for ZeroPad) - [ ] Base-conversion operator that takes a width and left-pads with zeros
- [ ] Pad with arbitrary character
- [ ] Wrap in parentheses (
WP
? orPN
orPT
for PareNThesize?) - [x] Bit-length (how many bits are in the binary representation of a number) (
BL
) - [ ] Rotate iterable left/right
- [x] Title-case (capitalize first letter of each run of letters) (
TC
) - [x] Initial caps (capitalize first letter of string) (
IC
) - [x] Round up, down, toward zero, to nearest (
>|
for round up,|<
for round down,RZ
for RoundZero,RN
for RoundNearest) - [ ] Keyed versions of
MN
andMX
, analogous toSK
(NK
for MinKey,MK
for MaxKey) - [ ] String versions of
MN
andMX
, analogous toSS
(MS
isn't available, so maybeLS
for LeastString andGS
for GreatestString) - [x] Sort in descending order (
DN
for DescendingNumeric,DS
for DescendingString) - [x] Sort keyed in descending order (
DK
) - [ ] Trim list (does the same thing as
TM
but works on Lists instead of Scalars) (TL
) - [ ] Join on list/element (concatenate list or insert element between consecutive elements of list) (
JL
andJE
) - [ ] Wrap in list (unary, binary, and maybe ternary versions) (
WL
or maybeWS
for WrapSingleton,WP
for WrapPair,WT
for WrapTriple--maybeWL
has unary and binary versions, but then there's alsoWS
that's only unary?) - [ ] Cartesian power (
CW
, or maybeCE
by analogy toE
for Exponential) - [ ] Power set, i.e. list of all subsets (
PS
) - [x] A version of
Z
that, given a list of strings, pads with spaces and returns a list of strings rather than a list of lists of characters (ZJ
for ZipJoin, by quasi-analogy toMJ
) - [ ] Versions of zip and weave that cycle the shorter list(s) (
ZC
andWC
) - [x] A version of
HV
that rounds up instead of down (HU
) - [ ] Non-cyclically-indexing version of
@
(returns nil when out of bounds; possibly extends iterable when out of bounds as an lvalue) (maybeEA
for ElementAt,IA
for ItemAt, orAI
for AtIndex?) - [ ] One-based indexing (
\@
, with a unary version that gets the last element) - [x] Random shuffle (
SH
) - [ ] Various triangular matrices
- [ ] Reversed identity matrix (
RY
, by analogy withEY
?) - [ ] Euclidean norm (
ED
for EuclideanDistance, orHY
for HYpotenuse?) - [ ] Dot product (
DP
) - [ ] Convolution (
CV
, maybe alsoVT
for ConvolutionTrimmed to the size of the bigger input) - [x] Log base 2 and base 10 (
LB
for LogBinary,LD
for LogDecimal)
- [ ] Factors
- [ ] Is prime?
- [ ] Prime factors
- [ ] Combinations with replacement
- [ ] Combinations without replacement
- [ ] All subsets