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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:54:11+00:00 2026-06-05T07:54:11+00:00

I have several questions related curried function. Here I ask them one-by-one 1) http://twitter.github.com/scala_school/basics.html

  • 0

I have several questions related curried function. Here I ask them one-by-one

1) http://twitter.github.com/scala_school/basics.html gives an example of curried function — I thought it’s a function definition, but actually it’s not. The REPL does not recognize this as a valid statement at all.

multiplyThenFilter { m: Int =>   m * 2 } { n: Int =>   n < 5}

2) Why can’t we define a function from partially parameterized method? i.e., what’s wrong with the following definition?

scala> def multiply(m: Int, n: Int): Int = m * n
multiply: (m: Int, n: Int)Int

scala> val timesTwo = multiply(2,_)
<console>:11: error: missing parameter type for expanded function ((x$1) => multiply(2, x$1))
       val timesTwo = multiply(2,_)
                                 ^

3) Why can’t we make a partially parameterized function curried? i.e., what’s wrong with the following definition?

scala> (multiply(_,_)).curried
  res13: Int => (Int => Int) = <function1>  // THIS IS OK

scala> (multiply(20,_)).curried
<console>:12: error: missing parameter type for expanded function ((x$1) => multiply(20, x$1))
              (multiply(20,_)).curried
                           ^
  • 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-05T07:54:13+00:00Added an answer on June 5, 2026 at 7:54 am

    Question 1

    The Scala School example is confusing—it’s definitely not a definition. There’s an issue open for it on GitHub, so maybe it’s a bug. You can imagine a reasonable definition might look like this:

    def multiplyThenFilter(f: Int => Int)(p: Int => Boolean): Int => Option[Int] = {
      i =>
        val j = f(i)
        if (p(j)) Some(j) else None
    }
    

    (Or, equivalently, f andThen (Some(_) filter p).)

    Then the example would be a function that doubles its input and returns the result in a Some if it’s less than 5, and a None otherwise. But nobody knows exactly what the author intended until there’s a response to that issue.


    Question 2

    The reason that your timesTwo doesn’t work is just that the Scala compiler doesn’t support that kind of type inference—see this question and my answer there for a bit of related detail. You’ll need to go with one of the following:

    def multiply(m: Int, n: Int): Int = m * n    
    val timesTwo = multiply(2, _: Int)
    
    def multiply(m: Int)(n: Int): Int = m * n    
    val timesTwo = multiply(2) _
    

    I.e., if you want type inference here you’ll need to use multiple parameter lists. Otherwise you have to help the compiler out with the type.


    Question 3

    For your third question, assume we’ve got the following to avoid the issue in your second question:

    val timesTwo = multiply(2, _: Int)
    

    This is a Function1, which just doesn’t have a curried method—you need a Function2 (or Function3, etc.) for that.

    It just doesn’t make sense to talk about currying a function with a single argument. Currying takes a function with multiple arguments and gives you a function taking a single argument that returns another function (which itself possibly takes a single argument and returns another function, etc.).

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

Sidebar

Related Questions

I have several related questions and post under one topic for clarity's sake. #
Several questions has been asked related to this error, but each one of them
Ok, I have seen several questions related to this issue, and I have tried
There are several questions related to ScrollViewer that I've researched, but none of them
I have read Django - CSRF verification failed and several questions (and answers) related
I have just discovered the joy of bitflags. I have several questions related to
I have posted several questions related to this problem I am having and I
I did search around various questions related to the one I'm about to ask.
I have two related questions one general and one specific to the project I'm
I have several questions: 1. What's the difference between isoMDS and cmdscale? 2. May

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.