pip icon indicating copy to clipboard operation
pip copied to clipboard

Ideas for new operators

Open dloscutoff opened this issue 3 years ago • 1 comments

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 and DW)
  • [ ] 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; or PL for PadLeft, PR for PadRight, PC for PadCentered)
  • [ ] Left-pad with zeros (LZ for LeftZero; or ZP for ZeroPad)
  • [ ] Base-conversion operator that takes a width and left-pads with zeros
  • [ ] Pad with arbitrary character
  • [ ] Wrap in parentheses (WP? or PN or PT 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 and MX, analogous to SK (NK for MinKey, MK for MaxKey)
  • [ ] String versions of MN and MX, analogous to SS (MS isn't available, so maybe LS for LeastString and GS 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 and JE)
  • [ ] Wrap in list (unary, binary, and maybe ternary versions) (WL or maybe WS for WrapSingleton, WP for WrapPair, WT for WrapTriple--maybe WL has unary and binary versions, but then there's also WS that's only unary?)
  • [ ] Cartesian power (CW, or maybe CE by analogy to E 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 to MJ)
  • [ ] Versions of zip and weave that cycle the shorter list(s) (ZC and WC)
  • [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) (maybe EA for ElementAt, IA for ItemAt, or AI 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 with EY?)
  • [ ] Euclidean norm (ED for EuclideanDistance, or HY for HYpotenuse?)
  • [ ] Dot product (DP)
  • [ ] Convolution (CV, maybe also VT for ConvolutionTrimmed to the size of the bigger input)
  • [x] Log base 2 and base 10 (LB for LogBinary, LD for LogDecimal)

dloscutoff avatar May 27 '21 01:05 dloscutoff

  • [ ] Factors
  • [ ] Is prime?
  • [ ] Prime factors
  • [ ] Combinations with replacement
  • [ ] Combinations without replacement
  • [ ] All subsets

mathcat4 avatar Jan 04 '23 08:01 mathcat4