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 8704453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:06:33+00:00 2026-06-13T03:06:33+00:00

I need to map through a List[(A,B,C)] to produce an html report. Specifically, a

  • 0

I need to map through a List[(A,B,C)] to produce an html report. Specifically, a

List[(Schedule,GameResult,Team)]

Schedule contains a gameDate property that I need to group by on to get a

Map[JodaTime, List(Schedule,GameResult,Team)]

which I use to display gameDate table row headers. Easy enough:

val data = repo.games.findAllByDate(fooDate).groupBy(_._1.gameDate)

Now the tricky bit (for me) is, how to further refine the grouping in order to enable mapping through the game results as pairs? To clarify, each GameResult consists of a team’s “version” of the game (i.e. score, location, etc.), sharing a common Schedule gameID with the opponent team.

Basically, I need to display a game result outcome on one row as:

3 London Dragons vs. Paris Frogs 2

Grouping on gameDate let’s me do something like:

data.map{case(date,games) =>
  // game date row headers
  <tr><td>{date.toString("MMMM dd, yyyy")}</td></tr>

  // print out game result data rows
  games.map{case(schedule,result, team)=>
    ...
    // BUT (result,team) slice is ungrouped, need grouped by Schedule gameID
  }
}

In the old version of the existing application (PHP) I used to

for($x = 0; $x < $this->gameCnt; $x = $x + 2) {...}

but I’d prefer to refer to variable names and not the come-back-later-wtf-is-that-inducing:

games._._2(rowCnt).total games._._3(rowCnt).name games._._1(rowCnt).location games._._2(rowCnt+1).total games._._3(rowCnt+1).name

maybe zip or double up for(t1 <- data; t2 <- data) yield(?) or something else entirely will do the trick. Regardless, there’s a concise solution, just not coming to me right now…

  • 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-13T03:06:34+00:00Added an answer on June 13, 2026 at 3:06 am

    Maybe I’m misunderstanding your requirements, but it seems to me that all you need is an additional groupBy:

    repo.games.findAllByDate(fooDate).groupBy(_._1.gameDate).mapValues(_.groupBy(_._1.gameID))
    

    The result will be of type:

    Map[JodaTime, Map[GameId, List[(Schedule,GameResult,Team)]]]
    

    (where GameId is the type of the return type of Schedule.gameId)

    Update: if you want the results as pairs, then pattern matching is your friend, as shown by Arjan. This would give us:

    val byDate = repo.games.findAllByDate(fooDate).groupBy(_._1.gameDate)
    val data = byDate.mapValues(_.groupBy(_._1.gameID).mapValues{ case List((sa, ra, ta), (sb, rb, tb)) => (sa, (ta, ra), (tb, rb)))
    

    This time the result is of type:

    Map[JodaTime, Iterable[ (Schedule,(Team,GameResult),(Team,GameResult))]]
    

    Note that this will throw a MatchError if there are not exactly 2 entries with the same gameId. In real code you will definitely want to check for this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to map a class which has a list of Enums to a
I have an HTML select list (let's call it List A) that is dynamically
I need an associative container that makes me index a certain object through a
Need a map reduce function by mongo in php This my mongo structure [_id]
I need to map most of the computer memory as uswc to take advantage
I need to map a many-to-many relationship using Entity Framework Code First. Its a
I need to map a single fixed sized array array to multiple properties. For
I have custom map image with specific height and width. i need to map
I have a simple requirement, i need a map of type . however i
I have a number, say 123456, and I need to map it to a

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.