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
Discussion posts and replies are publicly visible
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) ) ) ) )
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 )
Already answered here - community.appian.com/.../how-to-iterate-through-a-string