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

The Archive Base Latest Questions

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

Are these functions exactly same? That is, are 1st and 2nd syntax just convenient

  • 0

Are these functions exactly same? That is, are 1st and 2nd syntax just convenient shorthand for the last syntax? Or is there some theoretical or practical difference, and if so, what is it?

let f1 a b = a + b

let f2 a = (fun b -> a + b)

let f3 = (fun a -> (fun b -> a + b) )

They seem the same to me, f1 5, f2 5 and f3 5 seem to return identical value, for instance. Just checking I’m not making invalid assumption here. In other words, I hope a knowledge-based answer, not one saying “Yeah, I believe they are the same”.

  • 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-13T14:54:25+00:00Added an answer on June 13, 2026 at 2:54 pm

    Your assumption is correct, in this case, the functions are exactly the same.

    You can see that by inspecting the generated IL code (as demonstrated by Craig) and you can also see that by looking at the type inferred by the F# compiler. In both cases, you’ll see int -> int -> int. The F# language views that as a function that takes int and returns int -> int but it is actually compiled as a method with multiple arguments (for efficiency).

    If you write fun immediately following let .. = then the compiler turns that into a standard function. However, you can write code that is a bit different if you do some computation before returning the function:

    let f1 a b = printfn "hi"; a + b
    let f2 a = printfn "hi"; (fun b -> a + b)
    

    Now the two functions are very different, because the second one prints “hi” when you give it just a single argument (and then it returns a function that you can call):

    > let f = f2 1;;
    hi                      // The body is called, prints 
    val f : (int -> int)    // and returns function
    
    > f 2;;                 // This runs the body of 'fun'
    val it : int = 3        // which performs the additiion
    

    You can write the same code using f1, but the first command will just create a new function and the second command will print “hi” and do the addition.

    In this case, the generated IL code for f2 will be different. It will be a function that returns a function (of type FSharpFunc<int, int>). The type displayed by F# is also different – it will be int -> (int -> int) instead of int -> int -> int. You can use values of these two types in exactly the same ways, but it hints you that the first one may do some effects when you give it a single argument.

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

Sidebar

Related Questions

My question is not exactly the same as this one (it's not theoretical, there
Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string
I have 2 functions in C doing exactly the same thing, the only difference
I am a bit new to opencv. It seems that there are two functions
my Q is quite similar to these, but not exactly the same to: Returning
These functions may be hard to fit into a specific class, what's the best
Can someone clearly explain me how these functions of heap sort are working?? void
I have made a map of functions. all these functions are void and receive
Alright this is my first day with JQuery so have fun with these functions
This is the example code, I'm using these functions for a program, but scanf

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.