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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:01:39+00:00 2026-05-23T00:01:39+00:00

I have a function f: (a, b, c = 5, d = 0) ->

  • 0

I have a function f: (a, b, c = 5, d = 0) -> {...} that takes between 2 and 4 arguments.

I want to pass a “bound” version of this function that always uses the defaults for the last arguments, but uses specific values (say 1 and 2) for the first two arguments. That is, I want g: () -> f(1, 2).

If I were to do partial application, I would get g': (c = 5, d = 0) -> f(1, 2, c, d). That is, partial application wouldn’t enforce the zero-argument nature of g that I desire, instead giving me g' which takes between 0 and 2 arguments.

What is the technique for getting g from f called, if anything?

  • 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-23T00:01:39+00:00Added an answer on May 23, 2026 at 12:01 am

    Posting my comment as an answer: it seems that this question has little to do with functional programming or currying or partial application, but is instead precisely about taking a function that takes optional arguments that have defaults, and making a new function with no optional arguments in which the default arguments have been fixed.

    Call this conceptual transformation T. Assuming for some reason that partial application means that optional arguments remain optional (which need not be universal, but then again, the familiar functional programming languages — Haskell etc. — don’t even have optional arguments), there are at least two ways to get g from f.

      • Take f: (a, b, c = 5, d = 0) -> {....} which takes 2 to 4 arguments.
      • Generate the new function T(f) : (a,b) -> {...} which takes exactly 2 arguments. That is, T(f)(a,b) = f(a,b) = f(a,b,5,0).
      • Now do partial application on T(f) fixing its two arguments as 1 and 2, and call the resulting function g. That is, g() = T(f)(1,2) = f(1,2) = f(1,2,5,0).
      • Take f: (a, b, c = 5, d = 0) -> {....} which takes 2 to 4 arguments.
      • Do partial application on f fixing its first two arguments as 1 and 2, and call the resulting function g'. That is, g' : (c=5, d=0) -> f(1, 2, c, d). It takes between 0 and 2 arguments.
      • Generate the new function T(g) : () -> {....} which takes exactly 0 arguments. That is, T(g)() = g'() = g'(5, 0) = f(1, 2, 5, 0).

    In any case, the quandary in the question seems to hinge on T, rather than any aspect of functional programming or currying or partial application. I don’t know if T has enough of a point to have a standard name, but something like “fixing/binding default arguments” should be fine.

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

Sidebar

Related Questions

I have a function that takes a string-like argument. I want to decide if
I have a function that takes variadic arguments, that I obtain from func_get_args() .
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function that takes a struct, and I'm trying to store its
I have a function that takes pointer to pointer to struct. struct ABC; void
I have a function that takes a const D3DVECTOR3 *pos , but I have
I have a function that takes 2 parameters : 1 = XML file, 2
I have a function that takes longitude and latitude and converts it to x
I have a Python function that takes a numeric argument that must be an
I have created a function that takes a SQL command and produces output that

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.