Skip to main content
January 20, 2023
Question

logic Scenario

  • January 20, 2023
  • 3 replies
  • 0 views

lets say I had a word "Appian" 

now I need to covert into a list

expecting a result like below( Letter - (Number of times that particular letter is being repeated in the given word))

A-2

p-2

i-1

n-1

Please let me know logic to achieve this

    3 replies

    January 20, 2023

    Try something like this.

    a!localVariables(
      local!input: "Appian",
      local!inputChars: char(code(local!input)),
      local!uniqueInputChars: union(local!inputChars, local!inputChars),
      a!forEach(
        local!uniqueInputChars,
        a!map(
          inputChar: fv!item,
          count: length(
            wherecontains(fv!item, local!inputChars)
          )
        )
      )
    )

    January 20, 2023

    Hi @shilpak8740, Please refer this code.

    a!localVariables(
    local!name: upper("Appian"),
    local!namearray: a!forEach(
    items: enumerate(len(local!name)) + 1,
    expression: local!name[fv!index]
    ),
    local!union: union(local!namearray, local!namearray),
    local!result: a!forEach(
    items: local!union,
    expression: {
    fv!item & " - " & count(wherecontains(fv!item, local!namearray))
    }
    ),
    local!result
    )

    harshitb6843
    January 20, 2023