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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:20:33+00:00 2026-05-11T02:20:33+00:00

Messing around with ‘extension functions’ for the List module. (I spent quite a while

  • 0

Messing around with ‘extension functions’ for the List module. (I spent quite a while developing ‘mapfold’ – which threads an accumulator like fold, but uses it as a parameter to create new values like map – then discovered that that is what List.scan_left does)

For generation of test data, I needed to do a cross product of two lists, This is what I came up with:

///Perform cross product of two lists, return tuple let crossproduct l1 l2 =     let product lst v2 = List.map (fun v1 -> (v1, v2)) lst     List.map_concat (product l1) l2 

Is this any good, or is there already some better way to do this?

Same question for this one:

///Perform cross product of three lists, return tuple let crossproduct3 l1 l2 l3 =     let tuplelist = crossproduct l1 l2 //not sure this is the best way...     let product3 lst2 v3 = List.map (fun (v1, v2) -> (v1, v2, v3)) lst2     List.map_concat (product3 tuplelist) l3 
  • 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. 2026-05-11T02:20:33+00:00Added an answer on May 11, 2026 at 2:20 am

    another option is to use F# ‘sequence expressions’ and write something like this:

    let crossproduct l1 l2 =   seq { for el1 in l1 do           for el2 in l2 do             yield el1, el2 };; 

    (actually, it is almost the same thing as what you wrote, because ‘for .. in .. do’ in sequence expression can be viewed as map_concat). This works with (lazy) sequences, but if you want to work with lists, you’d just wrap the code inside [ … ] rather than inside seq { … }.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Have a look at the Maven Guide for Hibernate Core… May 11, 2026 at 11:57 am
  • added an answer both of them are well formed xml formats. but, if… May 11, 2026 at 11:57 am
  • added an answer Agree with validator comment - validating usually helps. But, if… May 11, 2026 at 11:57 am

Related Questions

Messing around with 'extension functions' for the List module. (I spent quite a while
I am messing around with a toy interpreter in Java and I was considering
I was messing around with RhinoMocks this morning and couldn't run my tests because
I am messing around with Doctrine (version 1.0.3) to see if would make a
I'm messing around with some C code using floats, and I'm getting 1.#INF00, -1.#IND00
I've been messing around with the free Digital Mars Compiler at work (naughty I
I need to start messing with a vb.net(vs2008) project file and I'd like a
I have a tricky problem that I've been messing about with for a few
I seem to be missing something about LINQ. To me, it looks like it's
I'm missing something here: $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter =

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.