Man, am I a genius. Check out this sorting algorithm I just invented.
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait
example usage: ./sleepsort.bash 5 3 6 3 6 3 1 4 7
Name:
Anonymous2011-03-30 16:47
THIS IS A MESSAGE FROM THE SUSSIX DEV TEAM (ME)
/*
* Inspired by the valiant /prog/lodtyes
* one of my personalities wrote an OMP
* implementation.
*
* Since we are currently training SCC
* (SCC Compiles C) we currently have to
* use GCC to compile it.
*/
/*
* @file sleepsort.c
* @brief sorts numbers
*
* @compile gcc sleepsort.c -fopenmp -o sleepsort
*
* @author Gerald Jay Sussman (Massachvsetts Institvte of Technology)
*
* Copyright (C) 2011 Gerald Jay Sussman and the Massachvsetts
* Institvte of Technology. All rights reserved.
*
* The new BSD License is applied to this software, see LICENSE.txt
*/
Just run an insertion sort over the output if you're worried about race conditions. This ensures that the numbers are relatively close to their ending points.
Terribly inaccurate with anything other than integers, but you can give arguments like 0.003 "sqrt(2)" 10e-3, for what it's worth.
Name:
Anonymous2011-03-31 20:49
Name:
Anonymous2011-03-31 20:58
way to ruin a good python thread
Name:
Anonymous2011-03-31 22:44
If you're sorting very large groups of numbers, unless your CPU can spawn the necessary number of threads, the accuracy will be compromised by shit like thread quantums.
Woah this thread is still going? OP here, and I've given up on prog the last few months after it went downhill (possibly partly my fault as I brought check my dubs ^__^ here. But now I'm back as I'm very bored this evening.
Recently I've been worked on a delicious object system for C with smalltalk style messaging. Actaully it's pointless but sort of fun. It could be used as the basis of ruby-style language intepreter or something.
>>115
That's kinda useless. You need to capture the output, hence waitpid.
Not that I find forking in Perl any more awkward than forking in C. But for Perl I suppose it's fair to call it awkward since there's no DWIM involved.