This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,3 @@
USE: concurrency.combinators
{ "Enjoy" "Rosetta" "Code" } [ print ] parallel-each

View file

@ -0,0 +1,6 @@
'Enjoy Rosetta Code'.tokenize().collect { w ->
Thread.start {
Thread.sleep(1000 * Math.random() as int)
println w
}
}.each { it.join() }

View file

@ -0,0 +1,4 @@
smoutput&>({~?~@#);:'Enjoy Rosetta Code'
Rosetta
Code
Enjoy

View file

@ -0,0 +1,12 @@
:- object(concurrency).
:- initialization(output).
output :-
threaded((
write('Enjoy'),
write('Rosetta'),
write('Code')
)).
:- end_object.

View file

@ -0,0 +1,5 @@
ParallelDo[
Pause[RandomReal[]];
Print[s],
{s, {"Enjoy", "Rosetta", "Code"}}
]

View file

@ -0,0 +1,13 @@
:- module concurrent_computing.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is cc_multi.
:- implementation.
:- import_module thread.
main(!IO) :-
spawn(io.print_cc("Enjoy\n"), !IO),
spawn(io.print_cc("Rosetta\n"), !IO),
spawn(io.print_cc("Code\n"), !IO).