Distributed programming: Difference between revisions

m (→‎{{header|Perl 6}}: Only mark actual code as being code for ease of automated testing)
Line 758:
console.log(msg.toString())
})</lang>
 
=={{header|Julia}}==
Julia was designed with distributed conmputing. in particular cluster computing, as a primary use target.
If a group of CPUs, including multiple cores on a single machine or a cluster running with paswordless ssh login, is used,
the following can be set up as an example:
<pre>
--------------------------------
From Julia the 1.0 online docs. File countheads.jl available to all machines:
------------</pre><lang julia>
function count_heads(n)
c::Int = 0
for i = 1:n
c += rand(Bool)
end
c
end</lang><pre>
------------------------------------</pre>
We then run the following on the primary client:
 
<lang julia>
using Distributed
@everywhere include_string(Main, $(read("count_heads.jl", String)), "count_heads.jl")
 
a = @spawn count_heads(100000000) # runs on an available processor
b = @spawn count_heads(100000000) # runs on another available processor
 
println(fetch(a)+fetch(b)) # total heads of 2 million coin flips, half on each CPU
</lang> {{output}} <pre>
100001564
</pre>
 
 
=={{header|LFE}}==
4,105

edits