This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton | |
{ | |
//>>Singleton | |
//David Simcha | |
static typeof(this) instance() @property | |
{ | |
if (!instantiated_) | |
{ | |
synchronized | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
void main() | |
{ | |
//Causes function number(int) to be called | |
number = 4; | |
//Declare integer number (same name as function) | |
int number; | |
//Set integer number to four. This will not call function number(int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio, std.random; | |
int main(string[] argv) | |
{ | |
writeln("Bucket Stort Sort"); | |
int[4] bucket; //Fyra olika hinkar (Egentligen en array av int som har de fyra platser 0, 1, 2 och 3). | |
for(int i = 0; i < 12; i++) //En for loop som kommer köras 12 gånger. Just siffran 12 är inte så viktig men jag tyckte det var en fin siffra. | |
bucket[uniform(0, 4)] += 1; //Lägg till ett i en hink som har det slumpmässiga nummer mellan 0 och 3. bucket[4] har platserna bucket[0 .. 3], alltså fyra platser. KÄLLA: http://dlang.org/phobos/std_random.html |
NewerOlder