Add function variants that take collections last

There are several functions that don’t take the collection they operate on last, which means they can’t be used in pipelines. For example:

  • delimit COLLECTION DELIMIT LAST should be delimit DELIMIT LAST COLLECTION to enable slice "a" "b" "c" | delimit ", " " "
  • split STRING DELIM should be split DELIM STRING to enable "a b c" | split " "
  • hasPrefix STRING PREFIX should be hasPrefix PREFIX STRING to enable "abc" | hasPrefix "a"

Here are a few others I found with a cursory search:

  • isset
  • sort
  • where

It would be useful to add “func2” variants, like “delimit2”, so we can use them with pipelines if desired. Or just change the existing funcs to work that way; whichever works.

1 Like

Yeah, it’s a bit of a mess.

strings.TrimPrefix PREFIX STRING
strings.Trim STRING CUTSET

In addition to the inability to pipe into the function, I can never remember which one works which way, so I’m in the docs alot.

If we change the existing functions everyone would break.

Not sure what to do about this…

1 Like

If we change the existing functions everyone would break.

Well, it’s not v1 yet, so buyer beware. I suggested the “2” variants as an option that wouldn’t break compat.

1 Like