Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8319271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:16:23+00:00 2026-06-08T22:16:23+00:00

I have a result of type List[List[Map[String,String]]] and I would like to transform it

  • 0

I have a result of type List[List[Map[String,String]]]and I would like to transform it into List[Map[String,String]]. How would I do this in Scala?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:16:24+00:00Added an answer on June 8, 2026 at 10:16 pm

    This is helped me understand how flatten work.

    val a = List( List( Map( 11 -> 11 ), Map( 12 -> 12 ) ), List( Map( 21 -> 21 ), Map( 21 -> 21 ) ) )
    
    def flatten(ls: List[Any]): List[Any] = ls flatMap {
        case ms: List[_] => flatten(ms)
        case e => List(e)
    }
    
    flatten( a )
    

    /** Converts this $coll of traversable collections into
       *  a $coll in which all element collections are concatenated.
       *
       *  @tparam B the type of the elements of each traversable collection. 
       *  @param asTraversable an implicit conversion which asserts that the element
       *          type of this $coll is a `Traversable`.
       *  @return a new $coll resulting from concatenating all element ${coll}s.
       *  @usecase def flatten[B]: $Coll[B]
       */
    def flatten[B](implicit asTraversable: A => /*<:<!!!*/ TraversableOnce[B]): CC[B] = {
        val b = genericBuilder[B] // incrementally build
        for (xs <- sequential)    // iterator for your collection
          b ++= asTraversable(xs) // am i traversable ?
        b.result                  // done ... build me
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
We have a number of Scala classes returning Map[String,String] (key,value) results for storage in
Possible Duplicate: Scala map containing mix type values I have a situation where in
I have an object defined as follow: protected Map<String, ? extends List<? extends LightGeometry>>
I have a query with single result. The result is an anonymouse type. How
I have the result of one API (FourSquare) giving me this.. [[4e01728f814d9dac7d52b93d,Bark Boutique,40.7143528,-74.0059731],[4d9f92dfaffda35d5db2a748,Bark Boutique,40.7143528,-74.0059731]]
I have a Result object that lets me pass around a List of event
I have a result from a query like the below, which does not have
I'd like to group a sequence into a map of sequences, based on a
I have a map that I need to map to a different type, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.