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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:38:49+00:00 2026-05-13T14:38:49+00:00

I wonder what this means in F#. a function taking an integer, which returns

  • 0

I wonder what this means in F#.
“a function taking an integer,
which returns a function which takes an integer and returns an integer.”

But I don’t understand this well.
Can anyone explain this so clear ?

[Update]:

> let f1 x y = x+y ;;

 val f1 : int -> int -> int

What this mean ?

  • 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-13T14:38:50+00:00Added an answer on May 13, 2026 at 2:38 pm

    F# types

    Let’s begin from the beginning.

    F# uses the colon (:) notation to indicate types of things. Let’s say you define a value of type int:

    let myNumber = 5
    

    F# Interactive will understand that myNumber is an integer, and will tell you this by:

    myNumber : int
    

    which is read as

    myNumber is of type int

    F# functional types

    So far so good. Let’s introduce something else, functional types. A functional type is simply the type of a function. F# uses -> to denote a functional type. This arrow symbolizes that what is written on its left-hand side is transformed into what is written into its right-hand side.

    Let’s consider a simple function, that takes one argument and transforms it into one output. An example of such a function would be:

    isEven : int -> bool
    

    This introduces the name of the function (on the left of the :), and its type. This line can be read in English as:

    isEven is of type function that transforms an int into a bool.

    Note that to correctly interpret what is being said, you should make a short pause just after the part “is of type”, and then read the rest of the sentence at once, without pausing.

    In F# functions are values

    In F#, functions are (almost) no more special than ordinary types. They are things that you can pass around to functions, return from functions, just like bools, ints or strings.

    So if you have:

    myNumber : int
    isEven : int -> bool
    

    You should consider int and int -> bool as two entities of the same kind: types. Here, myNumber is a value of type int, and isEven is a value of type int -> bool (this is what I’m trying to symbolize when I talk about the short pause above).

    Function application

    Values of types that contain -> happens to be also called functions, and have special powers: you can apply a function to a value. So, for example,

    isEven myNumber
    

    means that you are applying the function called isEven to the value myNumber. As you can expect by inspecting the type of isEven, it will return a boolean value. If you have correctly implemented isEven, it would obviously return false.

    A function that returns a value of a functional type

    Let’s define a generic function to determine is an integer is multiple of some other integer. We can imagine that our function’s type will be (the parenthesis are here to help you understand, they might or might not be present, they have a special meaning):

    isMultipleOf : int -> (int -> bool)
    

    As you can guess, this is read as:

    isMultipleOf is of type (PAUSE) function that transforms an int into (PAUSE) function that transforms an int into a bool.

    (here the (PAUSE) denote the pauses when reading out loud).

    We will define this function later. Before that, let’s see how we can use it:

    let isEven = isMultipleOf 2
    

    F# interactive would answer:

    isEven : int -> bool
    

    which is read as

    isEven is of type int -> bool

    Here, isEven has type int -> bool, since we have just given the value 2 (int) to isMultipleOf, which, as we have already seen, transforms an int into an int -> bool.

    We can view this function isMultipleOf as a sort of function creator.

    Definition of isMultipleOf

    So now let’s define this mystical function-creating function.

    let isMultipleOf n x =
        (x % n) = 0
    

    Easy, huh?

    If you type this into F# Interactive, it will answer:

    isMultipleOf : int -> int -> bool
    

    Where are the parenthesis?

    Note that there are no parenthesis. This is not particularly important for you now. Just remember that the arrows are right associative. That is, if you have

    a -> b -> c
    

    you should interpret it as

    a -> (b -> c)
    

    The right in right associative means that you should interpret as if there were parenthesis around the rightmost operator. So:

    a -> b -> c -> d
    

    should be interpreted as

    a -> (b -> (c -> d))
    

    Usages of isMultipleOf

    So, as you have seen, we can use isMultipleOf to create new functions:

    let isEven = isMultipleOf 2
    let isOdd = not << isEven
    let isMultipleOfThree = isMultipleOf 3
    let endsWithZero = isMultipleOf 10
    

    F# Interactive would respond:

    isEven : int -> bool
    isOdd : int -> bool
    isMultipleOfThree : int -> bool
    endsWithZero : int -> bool
    

    But you can use it differently. If you don’t want to (or need to) create a new function, you can use it as follows:

    isMultipleOf 10 150
    

    This would return true, as 150 is multiple of 10. This is exactly the same as create the function endsWithZero and then applying it to the value 150.

    Actually, function application is left associative, which means that the line above should be interpreted as:

    (isMultipleOf 10) 150
    

    That is, you put the parenthesis around the leftmost function application.

    Now, if you can understand all this, your example (which is the canonical CreateAdder) should be trivial!

    Sometime ago someone asked this question which deals with exactly the same concept, but in Javascript. In my answer I give two canonical examples (CreateAdder, CreateMultiplier) inf Javascript, that are somewhat more explicit about returning functions.

    I hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 293k
  • Answers 293k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Corrected Answer You can easily listen for keyboard events occurring… May 13, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer This problem is a good brain teaser. It should be… May 13, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer It is not useful to consider HTML5 as a single… May 13, 2026 at 6:30 pm

Related Questions

I would like to stub the #class method of a mock object: describe Letter
I am reading the document of GNU Make. Here is an example %.d: %.c
As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what
I wonder if someone can help: Long story short, I'm using MSSQL2005 to build
std::auto_ptr is broken in VC++ 8 (which is what we use at work). My

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.