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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:17:54+00:00 2026-05-30T14:17:54+00:00

Attempting to do some asynchronous programming via threads. To start with, I am trying

  • 0

Attempting to do some asynchronous programming via threads. To start with, I am trying a simple case: mapping a list in parallel. The code so far looks like:

let doWork (x:('a -> string)) (y:'a) (z:string ref) (finished:bool ref) =
    ThreadPool.QueueUserWorkItem( fun _ -> z:= x y
                                           finished:= true)
let dualmap (x:'a list) (y:'a -> string) (z:string -> 'b) = 
    let acc = []
    let rec dual (x:'a list) (y:'a -> 'b) (acc:'b list) = 
            match x with
            | [] -> acc
            | [i] -> (y i)::acc
            | i::j::tl -> let un      = ref ""
                          let deux    = ref ""
                          let unfin   = ref false
                          let deuxfin = ref false
                          doWork y i un   unfin   |> ignore //case i
                          doWork y j deux deuxfin |> ignore //case j
                          while not(unfin)||not(deuxfin) do Thread.Sleep(0)
                          let uno  = z !un
                          let dos  = z !deux 
                          dual tl y (dos::(uno::acc))
    dual x y acc

However, I am not sure how to get the threads to do work, since they seem to be obj -> unit rather than 'a -> 'b or 'a -> 'b -> 'c, which is what I would need.

Instead, I have to make sure I know how to convert every object I hve into a string, and then convert it back. It seems like there must be an easier way to do this?

  • 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-30T14:17:56+00:00Added an answer on May 30, 2026 at 2:17 pm

    Are you wanting to do something like this?

    let asyncMap f items = 
      let rec loop acc items =
        async {
          match items with
          | [] -> return List.rev acc
          | [x] -> 
            let! a = f x
            return! loop (a::acc) []
          | x::y::rest ->
            let! a = f x
            let! b = f y
            return! loop (b::a::acc) rest
        }
      loop [] items
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to build some C++ code that requires the Windows 7.0 SDK header
I am attempting to wrap some C code in Python using Pyrex. I've run
Currently attempting to get some code to compile using Lejos for the Lego NXT
I am attempting to do some calculations on a simple ruby screen. Lets say
I am attempting to write some Java code that takes an image from a
I am attempting to write some code that will expediently process video frames. I
Hi I have been working on this code today after attempting some of the
I am attempting to test some code that uses Request.Item(key) but I can not
I'm attempting to utilize some code found here: http://androidtabs.googlecode.com/svn/trunk/ This includes the bases classes
I am attempting to parse some JSON from a URL via Flash/AS3. Here's my

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.