From 6529748da383c52c6cd1487b86b051b15047d48e Mon Sep 17 00:00:00 2001 From: NickPapanastasiou Date: Sun, 7 Jun 2015 22:30:16 -0400 Subject: Prompt addition of D --- .d.html.markdown.swp | Bin 0 -> 12288 bytes d.html.markdown | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .d.html.markdown.swp create mode 100644 d.html.markdown diff --git a/.d.html.markdown.swp b/.d.html.markdown.swp new file mode 100644 index 00000000..f310c87d Binary files /dev/null and b/.d.html.markdown.swp differ diff --git a/d.html.markdown b/d.html.markdown new file mode 100644 index 00000000..9f322423 --- /dev/null +++ b/d.html.markdown @@ -0,0 +1,61 @@ +--- +language: d +filename: learnd.d +contributors: + - ["Nick Papanastasiou", "www.nickpapanastasiou.github.io"] +lang: en +--- + +If you're like me and spend way to much time on the internet, odds are you've heard +about [D](http://dlang.org/). The D programming language is a modern, general-purpose, +multi-paradigm language with fantastic support for OOP, functional programming, metaprogramming, +and easy concurrency and parallelism, and runs the gamut from low-level features such as +memory management, inline assembly, and pointer arithmetic, to high-level constructs +such as higher-order functions and generic structures and functions via templates, all with +a pleasant syntax, and blazing fast performance! + +D is actively developed by Walter Bright and Andrei Alexandrescu, two super smart, really cool +dudes. With all that out of the way, let's look at some examples! + +'''d +// You know what's coming... +import std.stdio; + +// args is optional +void main(string[] args) { + writeln("Hello, World!"); +} + +// Conditionals and loops work as expected. +import std.stdio; + +void main() { + for(int i = 0; i < 5; i++) { + writeln(i); + } + + auto n = 1; // use auto for type inferred variables + + while(n < 10_000) { + n += n; + } + + do { + n -= (n / 2); + } while(n > 0); + + // For and while are nice, but in D-land we prefer foreach + foreach(i; 1..int.max) { // The .. creates a continuous range + if(n % 2 == 0) + writeln(i); + } + + foreach_reverse(i; short.max) { + if(n % 2 == 1) + writeln(i); + else + writeln("No!"); + } +} + +''' -- cgit v1.2.3 From de5d895079abaa81d83734a332f993a7fced8282 Mon Sep 17 00:00:00 2001 From: NickPapanastasiou Date: Sun, 7 Jun 2015 22:30:44 -0400 Subject: Prompt addition of D --- .d.html.markdown.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .d.html.markdown.swp diff --git a/.d.html.markdown.swp b/.d.html.markdown.swp deleted file mode 100644 index f310c87d..00000000 Binary files a/.d.html.markdown.swp and /dev/null differ -- cgit v1.2.3