Let's unify all the data related actions (except 'Add a variable' and 'Set a data value') into the 'Calculate a value' action by implementing cases for string, list, and file data types alongside the existing integer support. Each calculation would support a pair of inputs or single value and NULL for each data type by performing the appropriate operation to calculate a desirable output based on the data types inputed. If a constructed logical operation isn't supported, then a graceful failure would be in order.

95% of the operations I a propose to incorporate here are already done and linked (a few of which twistor and I did for #745314: Action: transform text); what's left is to merge all of it into one very valuable action. Then we will also need an upgrade path for the existing 'Add / Remove an item to/from a list'.

This plan started out simply as an attempt to provide a simple, yet robust improvement to the current method of combining two strings, ie "[first name] + [last name]", using the token input with a space between two values. ...But then I thought about that other issue... investigated a little further, and everything seemed to line up perfectly...

The Plan

  • + Addition {Plus Sign} : Combinations and Appendages
  • - Subtraction {Minus Sign} : Differences and Removals
  • × Multiplication {Product Symbol} : Commutations and Joins
  • ÷ Division {Obelus Symbol} : Distributions and Splits
  • Related functions

    It will also be possible to reuse the functions above for creating more complex operations, like mean and multiplicative inverse and Cartesian product, though these can also be directly implemented with the action. Sorting and reversing lists and strings is already implemented to work numerically and alphabetically would lend to this and is as well, see #745314: Action: transform text.

    For more wiki reading, see String operations, String functions, Operations on Functions.

    Comments

    mitchell’s picture

    Issue summary: View changes

    added link to issue

    mitchell’s picture

    Issue summary: View changes

    added link

    mitchell’s picture

    Issue summary: View changes

    l

    mitchell’s picture

    Issue summary: View changes

    l

    mitchell’s picture

    Issue summary: View changes

    multiplication of an integer

    mitchell’s picture

    Issue summary: View changes

    string and number multiplication

    mitchell’s picture

    Issue summary: View changes

    explode link to code

    mitchell’s picture

    Issue summary: View changes

    rewriting intro text

    mitchell’s picture

    Issue summary: View changes

    wc

    mitchell’s picture

    Component: Rules Core » Rules Engine
    Issue tags: +data transforms
    mitchell’s picture

    Combining files. Added

    mitchell’s picture

    Issue summary: View changes

    files and conditions

    mitchell’s picture

    Issue summary: View changes

    a

    mitchell’s picture

    Title: 'Calculate a value' - support lists & other data types » Calculate a value: support strings, lists, & files
    Issue tags: +lists and loops

    Changing title and tagging 'lists and loops' related to #1525582: Action: generate a list from an integer.

    mitchell’s picture

    Marked #1342520: Calculate a value with an empty input as a duplicate of this issue.

    mitchell’s picture

    Issue summary: View changes

    updates

    mitchell’s picture

    Issue summary: View changes

    list addition link

    mitchell’s picture

    Issue summary: View changes

    two lists