Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,9 @@
|
|||
import System.Environment
|
||||
import Control.Concurrent
|
||||
import Control.Concurrent.Async
|
||||
|
||||
sleepSort :: [Int] -> IO [()]
|
||||
sleepSort = mapConcurrently (\x -> threadDelay (x*10^4) >> print x)
|
||||
|
||||
main :: IO [()]
|
||||
main = getArgs >>= sleepSort . map read
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
input = [3,2,4,7,3,6,9,1]
|
||||
output = Int[]
|
||||
|
||||
@sync for i in input
|
||||
@async begin
|
||||
sleep(i)
|
||||
push!(output, i)
|
||||
end
|
||||
end
|
||||
|
||||
@assert output == sort(input)
|
||||
println(output)
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
// rust 0.9
|
||||
use std::thread;
|
||||
|
||||
fn main()
|
||||
{
|
||||
let args = std::os::args();
|
||||
for arg in args.tail().iter()
|
||||
{
|
||||
let n = from_str::<u64>(*arg).unwrap();
|
||||
do std::task::spawn
|
||||
{
|
||||
std::io::timer::sleep(n);
|
||||
println!("{}", n);
|
||||
}
|
||||
}
|
||||
fn sleepsort<I: Iterator<Item=u32>>(nums: I) {
|
||||
let threads: Vec<_> = nums.map(|n|
|
||||
thread::spawn(move || {
|
||||
thread::sleep_ms(n);
|
||||
println!("{}", n); })).collect();
|
||||
for t in threads { t.join(); }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
sleepsort(std::env::args().skip(1).map(|s| s.parse().unwrap()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
/$>\ input until eof
|
||||
#/?<\?,/ foreach: fork
|
||||
\ &/:+ copy and\
|
||||
/:\?-; delay /
|
||||
\.# print and exit thread
|
||||
Loading…
Add table
Add a link
Reference in a new issue