with Clojure threading long running processes and comparing their returns

后端 未结 2 1041
别那么骄傲
别那么骄傲 2021-01-02 19:58

I have two different function on two very large sets of data that need to be processed, in the end coming down to two Boolean values. those values need to then be anded toge

2条回答
  •  情歌与酒
    2021-01-02 20:38

    Your approach is fairly normal Clojure code. One other choice is to use promises or if you need more complex processing you could consider using something like lamina or if you feel like living on the bleeding edge you could try core.async:

    (ns async-example.core
      (:require [clojure.core.async :refer :all])
    
    (defn example []
      (let [a (chan)  ; a channel for a to report it's answer
            b (chan)  ; a channel for b to report it's answer
            output (chan)] ; a channel for the reporter to report back to the repl
        (go (! a (rand-nth [true false])))
        (go (! b (rand-nth [true false])))
        (go (>! output (and ( ( ( (

    Of course this is overkill for your situation, though it's tremendously fun anyway ;-)

提交回复
热议问题