Skip to main content
February 7, 2023
Solved

By using expression rule i need to get the sample output

  • February 7, 2023
  • 3 replies
  • 1 view

Hi

sample Input : {a,b,c},{100,200,300}


sample output :

a-100,a-200,a-300,b-100,b-200,b-300,
c-100,c-200,c-300

    Best answer by abhayd3663

    a!localVariables(
      local!a: { "a", "b", "c" },
      local!b: { 100, 200, 300 },
      joinarray(
        a!flatten(
          a!forEach(
            items: local!a,
            expression: a!localVariables(
              local!prevItem: fv!item,
              a!forEach(
                items: local!b,
                expression: concat(local!prevItem, "-", fv!item)
              )
            )
          )
        ),
        ","
      )
    )

    output: 

    "a-100,a-200,a-300,b-100,b-200,b-300,c-100,c-200,c-300"

    3 replies

    stefanhelzle0001
    Brainy
    February 7, 2023

    Can you share any existing code snippets? Is there a specific reason you now posted the third question which looks like being copied from some test?

    abhayd3663
    February 7, 2023

    a!localVariables(
      local!a: { "a", "b", "c" },
      local!b: { 100, 200, 300 },
      joinarray(
        a!flatten(
          a!forEach(
            items: local!a,
            expression: a!localVariables(
              local!prevItem: fv!item,
              a!forEach(
                items: local!b,
                expression: concat(local!prevItem, "-", fv!item)
              )
            )
          )
        ),
        ","
      )
    )

    output: 

    "a-100,a-200,a-300,b-100,b-200,b-300,c-100,c-200,c-300"

    mikes0011
    Brainy
    February 7, 2023

    fyi...

    The Expression Guru