0

Input: {param1=[x1,y1], param2=[p1,q1],param3=[m1,n1]....}

Output: [{param1=x1, param2=p1,param3=m1....},{param1=y1, param2=q1,param3=n1....}]

I need to convert this input Map<String,List<String>> to List<Map<String,String>> Any help is appreciated. Your help can save my day.. Thank you

1 Answer 1

1
val source =
    mapOf(
        "param1" to listOf("x1", "y1"),
        "param2" to listOf("p1", "q1"),
        "param3" to listOf("m1", "n1")
    )

val result = source.values.first().indices.map { index ->
    source.entries.associate { (param, list) -> param to list[index] }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, I'm new to fp and have been trying to do the same with zip and i was going no where.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.