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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:50:26+00:00 2026-06-03T14:50:26+00:00

I am converting several modules based on OCaml to F# and ran into something

  • 0

I am converting several modules based on OCaml to F# and ran into something like this

let [x; y; z] = map func1 ["a"; "b"; "c"]

where [x; y; z] is a list of identifiers and
map func1 ["a"; "b"; "c"] returns a list of functions.

Currently I am binding each value in the list to the identifier separately i.e.

let fList = map func1 ["a"; "b"; "c"]
let x = fList.[0]
let y = fList.[1]
let z = fList.[2]

The use of the identifiers is for a second function i.e.

func2 x y z 

I know I can modify func2 to accept a list, but since func2 in reality takes values along with each function for each parameter it would be even more work. i.e.

func2 (x g) (y h) (z i)

I have looked for ways to do this as efficiently as OCaml and came up empty.
I searched for unmap, deconstruct, and looked at the methods for List

Can F# map a list of values directly to a list of identifiers?

EDIT

The code I am converting does define a map function in its own library.

EDIT

@OnorioCatenacci It was just something I wrote as an example instead of trying to spend many minutes creating a real working example. The real code has a copyright so I can’t use it here without the full disclosure. The point I was trying to make was that I was not assigning constant values to identifiers but functions to identifiers. I only put in map func1 ["a"; "b"; "c"] to show that the functions were being generated as needed based on some input and not hardcoded. The real code builds logic circuit simulators and the functions returned are different logic circuits; think combinators. It is all part of an automated theorem prover. Tomas and Daniel understood the question and gave correct answers that I verified with the real code.

In other words func1 "a" will return a function using the parameter "a". map func1 ['a", "b", "c"] will return a list of functions. Since functions are first-class in F#, they can be returned as values.

  • 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-03T14:50:29+00:00Added an answer on June 3, 2026 at 2:50 pm

    You can apply map to a list and then use pattern matching to bind the elements to identifiers in F#. The syntax is exactly the same as in the sample you wrote:

    let [x; y; z] = List.map func1 ["a"; "b"; "c"] 
    

    The only problem with this example is that the F# compiler cannot statically verify that the result will be a list of length 3 and so it gives you a warning saying “Incomplete pattern matches on this expression.” In this example, it cannot actually happen, but if you, for example, redefined map incorrectly so that it would throw away the first element, the code would break.

    This is just a warning, so you can ignore it, but if you want to avoid it, you’ll need to use match and throw some custom exception in the unexpected case:

    match List.map func1 ["a"; "b"; "c"] with
    | [x; y; z] ->
       // Continue here if the pattern matching does not fail
       func2 (x g) (y h) (z i) 
    | _ -> invalidOp "Pattern matching failed"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am converting several modules based on OCaml to F# and ran into the
I am converting my app to use NDB. I used to have something like
I have been tasked with converting several php classes into java classes, which is
I am in the process of converting several queries which were hard-coded into the
I'm slowly converting my existing code into Delphi 2010 and read several of the
I've got several large MFC applications here, and converting them into any other format
I have evaluated several development tools for converting my informix SQL-based app. They are:
I'm new to C++ so I'm having trouble converting this into C++. Is there
We are upgrading/converting several old Access databases to MS-SQL. Many of these databases have
I have several questions concerning the controls like a button, if You could answer

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.