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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:27:18+00:00 2026-06-10T00:27:18+00:00

let myFunc x y = List.fold (&&) true [func1 x y; func2 x y]

  • 0
let myFunc x y =
    List.fold (&&) true [func1 x y; func2 x y]

I don’t know all the different operators and techniques in F#, but was hoping I could just plop some operator in place of “x y” for func1 and func2 to indicate to them “Just take my parameters” almost like how composition has implicit parameter pass through.

Alternatively, if someone can think of a much more straightforward and clean way of doing this that gets rid of the need for my function to hand it’s parameters in, let me know.

Also, if this is just not possible which seems entirely likely, let me know.

Thanks!

  • 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-10T00:27:19+00:00Added an answer on June 10, 2026 at 12:27 am

    I don’t think there is a nice way to thread the parameters of myfunc to the parameters of func1 and func2. However, your example is perhaps a bit over-simplified, because you could just write:

    let myfunc x y = 
      func1 x y && func2 x y
    

    I suppose that in reality, you have a larger number of functions and then using fold makes a good sense. In that case, you could use fold to combine the functions rather than using it to combine the results.

    If I simplify the problem a little and assume that func1 and func2 take the two arguments as a tuple (instead of taking them as two separate arguments), then you can write something like this:

    let func1 (a, b) = true
    let func2 (a, b) = true
    
    let myfunc = List.fold (fun f st a -> f a && st a) (fun _ -> true) [ func1; func2 ] 
    

    Now you do not need to pass the parameters around explicitly (to func1 and func2), but the arguments of fold got a bit more complicated. I think that’s fine, because you need to write that just once (and it is quite readable this way).

    However, if you’re fan of the point-free style (or just want to see how far you could get), you can define a few helper functions and then write the code as follows:

    /// Given a value, returns a constant function that always returns that value
    let constant a _ = a
    /// Takes an operation 'a -> b -> c' and builds a function that
    /// performs the operation on results of functions    
    let lift2 op f g x = op (f x) (g x)
    
    let myfunc2  = List.fold (lift2 (&&)) (constant true) [ ffunc1; ffunc2 ] 
    

    If you do not need arbitrary number of functions, then I’d simplify the code and not use fold at all. If you need to do that, then I think your version is very readable and not too long. The examples I wrote in this answer show that you can avoid passing the parameters by hand, but it makes the code a bit cryptic.

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

Sidebar

Related Questions

Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a function like: void myFunc(List<AClass> theList) { string[] stuff =
For this non-variadic example: int Func1(); double Func2(); void MyFunc( int, double ); int
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say, we have and list of objects in variable called articles, each object
Let's say you have two different categories of users with different profiles: one for
Let's say you have a function that returns a date: Date myFunc(paramA, paramB){ //conditionally
I have a function that uses setline(). For simplicity, let's call it function! MyFunc()
Let's say I have a large amount of files, say 20GB worth, all encrypted

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.