How to create list by deriving another list in scala -
i have list follow
list[string] = list(gateway = msc050, sequence = 176484,gateway = msc050, sequence = 176485)
i want create referring above follow
list[string] = list(50176484,50176485)
here have merger last 2 digit of gateway , sequence list. can 1 on this?
assuming list missing quotes:
val input: list[string] = list("gateway = msc050", "sequence = 176484", "gateway = msc050", "sequence = 176485") input.grouped(2).map { l => l(0).takeright(2) + l(1).split(' ').last }.tolist
output:
list(50176484, 50176485)
grouped(2)
allow iterate on every gateway/sequence pair. need last 2 digits gateway, , number sequence. i've done takeright
gateway, , splitting on spaces sequence (assuming sequence strings have space after equals).
Comments
Post a Comment