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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:21:35+00:00 2026-06-15T08:21:35+00:00

I have the following problem. I was trying to make a high-order function that

  • 0

I have the following problem. I was trying to make a high-order function that accepts two parameters: the String and the function type. Function type is defined this way:

(String, List[String]) => List[(String, List[String])]

I have also defined two functions f1 and f2 that has the same type. Afterwards I am trying to call myfun with f1 or f2. Here is the code:

object Main extends App {


def f1(t: (String,List[String])): List[(String,List[String])] = ...

def f2(t: (String,List[String])): List[(String,List[String])] =  ...

def myfun(tableName: String)(fn: (String,List[String]) => List[(String,List[String])]):  List[(String,List[String])] =
 ...

val res: List[(String,List[String])] = myfun("...")(f1)
res foreach println
val res2: List[(String,List[String])] = myfun("...")(f2)
res2 foreach println
}

and here is the error:

[error]  found   : (String, List[String]) => List[(String, List[String])]
[error]  required: (String, List[String]) => List[(String, List[String])]
[error]   val res: List[(String,List[String])] =  myfun("...")(f1)

I cannot understand why the compiler is complaining. Can someone explain it?

  • 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-15T08:21:36+00:00Added an answer on June 15, 2026 at 8:21 am

    Try this. Note the extra set of parenthesis surrounding the argument list to fn.

    def myfun(tableName: String)
             (fn: ((String,List[String])) => List[(String,List[String])]):  List[(String,List[String])] = ...
    

    Unfortunately this extra set of parenthesis is needed to distinguish

    Function1[(String, List[String]), List[(String,List[String])]] 
    

    from

    Function2[String, List[String], List[(String, List[String])]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve the following problem in Redis. I have a list that
I have following problem: I have to make a ASP.NET Webapplication with a two-row
I'm trying to solve the following problem: I have a download button that when
I have the following problem: I am trying to make 3 links/anchors (with padding
I have the following problem. Am trying to make a polymorphic call and the
I'm a newbie in bash scripts and have the following problem : I'm trying
Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I am trying to solve the following problem with Puppet: I have multiple nodes.
I am trying to solve the following problem. Lets say you have the the
I have the following code, The problem is when I'm trying to assign the

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.