find duplicate characters count in a string

input: "Banana",

output: "B---------------1" , "aaa---------------3", "nn---------------2" 

any one try it anthor way ..

{

a!localVariables(
local!data: "Banana",
local!len: len(local!data),
local!merge: union(
a!forEach(
items: enumerate(local!len) + 1,
expression: local!data[fv!index]
),
a!forEach(
items: enumerate(local!len) + 1,
expression: local!data[fv!index]
)
),
local!all: a!forEach(
items: enumerate(local!len) + 1,
expression: local!data[fv!index]
),
a!forEach(
items: local!merge,
expression: index(
local!data,
wherecontains(fv!item, local!all),
{}
) & "---------------" & count(wherecontains(fv!item, local!all))
)
)

}

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    a!localVariables(
    local!string : "appian training",
    local!chars : char(code(stripwith(local!string," "))),
    local!uniquechars : union(local!chars,local!chars),
    local!count : a!forEach(
    items: local!uniquechars,
    expression: a!map(
    item : fv!item,
    count : length(wherecontains(fv!item,local!chars))
    )
    ),
    local!output : a!forEach(
    items: local!count,
    expression: fv!item.item&"-------------"&fv!item.count,
    ),
    local!output
    )

Reply
  • 0
    Certified Associate Developer

    a!localVariables(
    local!string : "appian training",
    local!chars : char(code(stripwith(local!string," "))),
    local!uniquechars : union(local!chars,local!chars),
    local!count : a!forEach(
    items: local!uniquechars,
    expression: a!map(
    item : fv!item,
    count : length(wherecontains(fv!item,local!chars))
    )
    ),
    local!output : a!forEach(
    items: local!count,
    expression: fv!item.item&"-------------"&fv!item.count,
    ),
    local!output
    )

Children
No Data