From ab637d83f235a1766cbfc4c8a1d84cde4a670820 Mon Sep 17 00:00:00 2001 From: NickPapanastasiou Date: Sun, 7 Jun 2015 22:30:16 -0400 Subject: [PATCH] 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 0000000000000000000000000000000000000000..f310c87d09d4381c3283e1642e5faa599ef78ed7 GIT binary patch literal 12288 zcmeI2y>A>v7{(`vf{!>vq(TDe^+m`wzTG=JiGu7nQour3K%9bLA;ogd$WZ4HT4=2!Rj0z3;4a zy6JUaS$m1jr)L?ClZ@T}m%q9=^*Ouv2xD4i+u`>A9lhE~Eu2ewX7_eu-wFmht0t>U zp}p%U!L8nvdQ?hXd*PDYWUiB^17E7NIN| zx;0Iw9=&>JbK|H;AQFfKB7sOC5{LvMfk+?{xF-ns>KMC@OzxXxvobj!J93_Uji*Q; z5{LvMfk+?{hy)^mNFWl31R{Y*AQHF>3Gke;4<2CbqX!W@{{P?m{r?C4|Njm85&9as z3EhC+hOR?TLEoQX%tDVrUrjMqK)ap)BE=R=JB3jG3o4E3RP=sdIlb)nDJsbYi{C0C@1#6gqwQ<<)J~cKdb3UTBMZ~T9|8w_l*@i8(gzuM_4Cj)fd`wz>(;zF8Ay=Rg-9eQ~nC`~DYZ|nmlPMOgjn?gYW!m4 zbH)O zH#h&zRnzh3>U(x4Vyq*WQpO@LUdw)eb?1TZn`Fs1gVgVOf#W4!4r` zlyFCx9<3Cn&H@)nSnV$3bb-#{G(R7l?iiU<$)%ocLXc&JVv+NC3Q4of5X7@a=h91~ zxdL0jQ^r(|hQ@9acO-Tzk$I7)dmXkHK%g1yR_bDN3neIAa1B4< zlB6S3jh!)e%Wz&bHEnA%L@~IZai}%+{}ySQGITk9j^uSNTuK|#4~Q#89>d6>zNU|B zK|?-jlM-Pn5c*OUTz@UjBWX|@`o;F*^@LX9X#D=Sk0d2d7;TzRy`GgcM@-@v$} zb1NiWQkWkuT~@cr4-L7x!bpdW$i7YJOa)t+F^Vxx@WUNPQQSy-zT0jr^%Q>{nNXiQ zPne6sm0V|HnwYCIB;#lRx56gI=Ak!hjTns{7o`wdSec=Aw$6NwKpLY5gLWh*FOXtb zBk%|`Loi~cD2*MV2{bQ6*je31lPT=ThC?UHo&v5=^~#`&;1+%72c_^bL!PDyDN%t@ zSaoCXj#!w197D=FtI@GK8;#9y3)ezPSB~x48X1Jb6ud;0`qq>v%y43}k0sqCGeN-0 zT6vjNu#(FHBeA?|1m5HVbinBlTA<&wa#%R)>sQ+Qw7A0BHihM7Xqz@66Mpyxw#O{M?< literal 0 HcmV?d00001 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!"); + } +} + +'''