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

  • SEARCH
  • Home
  • 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 7681199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:17:15+00:00 2026-05-31T18:17:15+00:00

I search of method to resolve this initialization problem of tuple () with result

  • 0

I search of method to resolve this initialization problem of tuple () with result of a map, like this :

//My current state of cities
val listOfCity = IndexedSeq(new City1(), new City2())

// Function which compute my new state
val (newCity,exchange) = listOfCity.map{ city =>  computeNewCity(city,listOfCity)}    

The variable newCity contain the result ._1 of my tuple returned by computeNewCity() and the variable exchange contain the result ._2 of the same tuple.

The function computeNewCity() return a new version of my object city and an history of exchange, results of my exchange with other cities in listOfCity, it’s a tuple of type (City, Exchange)

How can i make this with help of functionnal programming ?

Thanks !
Sr

  • 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-05-31T18:17:16+00:00Added an answer on May 31, 2026 at 6:17 pm

    The problem is listOfCity.map{ city => computeNewCity(city,listOfCity)} returns an IndexedSeq[(City, Exchange)] (one tuple for each city in listOfCity), and obviously you can’t just assign it to a (City, Exchange) tuple. You could take first element or last:

    val (firstCity,exchange) = listOfCity.map{ city =>  computeNewCity(city,listOfCity)}.first
    
    val (lastCity,exchange) = listOfCity.map{ city =>  computeNewCity(city,listOfCity)}.last
    

    or get a tuple of two sequences (cities and their corresponding exchanges)

    val (cities,exchanges) = listOfCity.map{ city =>  computeNewCity(city,listOfCity)}.unzip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created little search method. The problem that its hard to read it
How can I chain metasearchs' search method ? @result = User.search(params[:search]).search(params[:filters]) We can call
I'm using Thinking Sphinx for full-text search, following this video . I'd like to
@RequestMapping(value = /user/search/{email}) public String auditUseremail(@PathVariable(email) String email,Map<String, Object> map) { System.out.println(email); } this
I have this search method: public List<Employeees> AutoSuggestEmployeee(string keyword, long employeeeTypeId, int count) {
I made this search method on my Entity Framework repo: public IEnumerable<Person> GetPersonsWithFilter(string filter)
i'm a beginner in .NET, and search since yesterday morning to resolve my problem
I need for Search method for a hashmap and I cant quite figure out
I have a search method that takes in a user-entered string, splits it at
I have a search-method which returns multiple items, each with several child-properties with references

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.