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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:02:23+00:00 2026-06-13T01:02:23+00:00

If the pipe operator is created like this: let (|>) f g = g

  • 0

If the pipe operator is created like this:

let (|>) f g = g f

And used like this:

let result = [2;4;6] |> List.map (fun x -> x * x * x)

Then what it seems to do is take List.Map and puts it behind (fun x -> x * x * x)
And doesn’t change anything about the position of [2;4;6]

So now it looks like this:

let result2 = [2;4;6] (fun x -> x * x * x) List.map

However this doesn’t work.

I am just learning f# for the first time now. And this bothered me while reading a book about f#. So I might learn what I’m missing later but I decided to ask anyway.

It is obvious though that I am missing something major. Since I can easily recreate the pipe operator. But I don’t get why it works. I might embarrass myself very soon as I learn more. Oh well.

  • 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-13T01:02:24+00:00Added an answer on June 13, 2026 at 1:02 am

    The pipe operator is simply syntactic sugar for chained method calls. It’s very similar to how linq expressions are expressed in C#.

    Explanation from here:

    Forward Pipe Operator
    I love this guy. The Forward pipe operator is simply defined as:

    let (|>) x f = f x
    

    And has a type signature:

    'a -> ('a -> 'b) -> 'b
    

    Which translates to: given a generic type ‘a, and a function which takes an ‘a and returns a ‘b, then return the application of the function on the input.

    Rather than explaining this, let me give you an example of where it can be used:

    // Take a number, square it, then convert it to a string, then reverse that string
    let square x         = x * x
    let toStr (x : int)  = x.ToString()
    let rev   (x : string) = new String(Array.rev (x.ToCharArray()))
    
    // 512 -> 1024 -> "1024" -> "4201"
    let result = rev (toStr (square 512))
    

    The code is very straight forward, but notice just how unruly the syntax looks. All we want to do is take the result of one computation and pass that to the next computation. We could rewrite it by introducing a series of new variables:

    let step1 = square 512
    let step2 = toStr step1
    let step3 = rev step2
    let result = step3
    

    But now you need to keep all those temporary variables straight. What the (|>) operator does is take a value, and ‘forward it’ to a function, essentially allowing you to specify the parameter of a function before the function call. This dramatically simplifies F# code by allowing you to pipe functions together, where the result of one is passed into the next. So to use the same example the code can be written clearly as:

    let result = 512 |> square |> toStr |> rev
    

    Edit:

    In F# what you’re really doing with a method call is taking a function and then applying it to the parameter that follows, so in your example it would be List.map (fun x -> x * x * x) is applied to [2;4;6]. All that the pipe operator does is take the parameters in reverse order and then do the application reversing them back.

    function: List.map (fun x -> x * x * x)
    parameter: [2;4;6]

    Standard F# call syntax: f g

    Reversed F# call syntax: g f

    Standard:

    let var = List.map (fun x -> x * x * x) [2;4;6]
    

    Reversed:

    let var = [2;4;6] |> List.map (fun x -> x * x * x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I create pipe in windows this way: CreatePipe(hRead, hWrite, &sec_atr, NULL) Then make
I created a pipe and I used dup2() to overwrite streams 1 & 2
In Unix shell programming the pipe operator is an extremely powerful tool. With a
A Named Pipe Server is created with hPipe = CreateNamedPipe( zPipePath, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE |
The pipe symbol | is used in Regular Expression as a sort of 'either'
I'm using some pipe and fork to execute a command like cat file.tar.gz |
How can you implement F#'s forward pipe operator in R? The operator makes it
I try to pipe appjs console to a file with this code: var fs
I'm trying to figure out the correct syntax to use the pipe operator |>
In F#, use of the the pipe-forward operator, |> , is pretty common. However,

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.