Page 1 of 1

Concatenate

Posted: Thu Apr 05, 2018 2:10 am
by webmaster
Sometimes a selector selects more than one element and we want to extract their concatenated values as a single value. The following function takes a separator and a sequence, and returns their concatenated values. To use this on your project, follow these instructions.

Code: Select all

function (separator sequence)
   Sequence.FirstOrDefault
      ·  Sequence.Fold
            ·  sequence
            ·  function (a b)
                  +
                     ·  a
                     ·  separator
                     ·  b
As a quick example, suppose your project contains a selector called PhoneNumbers that selects many elements on the page. Instead of just using a Select.PhoneNumbers action, which would extract the first phone number only, the following code would extract all phone numbers separated by a comma (this example also assumes you've pasted the code above into your project and called it Concatenate):

Code: Select all

Concatenate
   ·  ", "
   ·  Select.PhoneNumbers