RIP
Tutorial
Tags
Topics
Examples
eBooks
Tutorial by Examples
Checking if a Number is Prime
import std.stdio; bool isPrime(int number) { foreach(i; 2..number) { if (number % i == 0) { return false; } } return true; } void main() { writeln(2.isPrime); writeln(3.isPrime); writeln(4.isPrime); 5.isPrime.writeln; } ...
UFCS with ranges
void main() { import std.algorithm : group; import std.range; [1, 2].chain([3, 4]).retro; // [4, 3, 2, 1] [1, 1, 2, 2, 2].group.dropOne.front; // tuple(2, 3u) }
UFCS with Durations from std.datetime
import core.thread, std.stdio, std.datetime; void some_operation() { // Sleep for two sixtieths (2/60) of a second. Thread.sleep(2.seconds / 60); // Sleep for 100 microseconds. Thread.sleep(100.usecs); } void main() { MonoTime t0 = MonoTime.currTime(); some_opera...
Page 1 of 1
1
Cookie
This website stores cookies on your computer.
We use cookies to enhance your experience on our website and deliver personalized content.
For more details on our cookie usage, please review our
Cookie Policy
and
Privacy Policy
Accept all Cookies
Leave this website