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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:13:54+00:00 2026-06-13T10:13:54+00:00

How is the method product used in this code ? The result for this

  • 0

How is the method product used in this code ?

The result for this function is 3600

So product takes a function : f ,
f takes an Int parameter which returns an Int parameter.

But does (a: Int, b: Int) not indicate that a function which takes two Int parameters are returned ?

I’m confused as to what is is occuring in this line :
f(a) * product(f)(a + 1, b)

Complete function :

 def product(f: Int => Int)(a: Int, b: Int): Int =
    if(a > b) 1
    else {
     f(a) * product(f)(a + 1, b)
    }                                        
  product(x => x * x)(3 , 5)  
  • 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-13T10:13:55+00:00Added an answer on June 13, 2026 at 10:13 am

    In Scala, methods can have multiple parameter lists. In this example, the method product has two parameter lists: (f: Int => Int) and (a: Int, b: Int).

    The first parameter list contains one parameter named f, which is of type Int => Int (a function that takes an Int and returns an Int).

    The second parameter list contains two parameters named a and b which are both of type Int.

    The expressions product(f)(a + 1, b) and product(x => x * x)(3 , 5) simply call the method with all three parameters.

    The advantage of this is that you can “call” product with only the first parameter list. What you’ll then get is a function that you can call by supplying the second parameter list. For example:

    val fn = product(x => x * x)  // only the first parameter list is applied
    fn(3, 5)                 // fn is a function which you can pass the second list
    

    “Calling” product with only the first parameter list is called currying.

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

Sidebar

Related Questions

Why does this code produce the same output for both method calls? I would
I have written some code, and the Vigenere encryption is used in it. This
I used this code previously it worked fine and i was suggested to use
I've used this method to store my data to element while I fetch it
Can anyone provide either a method of using the following code that doesn't result
I used to use OpenC++ ( http://opencxx.sourceforge.net/opencxx/html/overview.html ) to perform code generation like: Source:
I have an EDM used to bring back a collection of Product entities within
Creating an Iphone application, I used to perform INSERT QUERY on different databases. But
My tableview is in this user interface: But when I start search the view
I need help to find the product and vendor ID of USB_Flash-drive, I used

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.