D - Example code
- Jon Frechette (10/10) Jul 29 2003 Hi folks,
- Jon Frechette (163/163) Jul 29 2003 Oops, I forgot to attach the source code. Got it this time.
Hi folks, I've just started trying to learn the D language and I really like it so far. It seems that the example code included with the compiler is pretty short on language features and uses no OOP at all. So, I created another version of the wordcount program that uses every D feature I could learn. I have attached the source code in case it might be of some value to Walter's effort. Ps: I may have recreated the wheel in places, so any comments would be welcomed by this newbie. Thanks
Jul 29 2003
Oops, I forgot to attach the source code. Got it this time. begin 666 wc.d M<W1R:6YG(%T =V]R9$-O=6YT3&ES=#L- M(%M=(&%R9W, *0T*>PT*("!I9B H(&%R9W,N;&5N9W1H(#T M('L <')I;G1F*" B57-A9V4Z('=C(&9I;&4 6V9I;&5S+BXN75QN(B I.R!R M="!T;W1A;$QI;F5S(#T M('=O<F1S(" 8VAA<G-<;B( *3L-"B <')I;G1F*" B+2TM+2T (" M+2TM M(&%R9W-;(&D 73L-" T*(" ('-T<FEN9R!S='( /2 H<W1R:6YG*2!F:6QE M.&0E.&0 (&EN("5S7&XB+"!C;W5N=',N;&EN97,L(&-O=6YT<RYW;W)D<RP M"B ("!P<FEN=&8H("(M+2TM+2 ("TM+2TM(" +2TM+2U<;B( *3L-"B M("!P<FEN=&8H(B4U9"4X9"4X9" =&]T86QS7&XB+"!T;W1A;$QI;F5S+"!T M;G1S(&9I;F17;W)D<R <W1R:6YG(&EN<'5T+"!O=70 =V]R9$-O=6YT3&ES M(" >PT*(" (&-H87( 8VAR(#T :6YP=71;(&D 73L-"B ("!I9B H(&ES M5V]R9$-H87(H(&-H<B I("D-"B (" ('L-"B (" (&-U<G)E;G17;W)D M('X](&-H<CL-"B (" (&EF(" :6Y7;W)D(#T](&9A;'-E("D-"B (" M(" :6Y7;W)D(#T =')U93L-"B (" ('T-"B ("!E;'-E("\O(&YO="!A M('=O<F0 8VAA< T*(" (" >PT*(" (" :68 *"!C:'( /3T (EQN(B I M9" ]/2!T<G5E("D-"B (" (" >PT*(" (" ("!I9B H(&-H<B ]/2 G M96YT5V]R9"!^/2!C:'([( T*(" (" (" ('T-"B (" (" 96QS90T* M(" (" (" ('L-"B (" (" ("!A9&17;W)D*"!C=7)R96YT5V]R9"P M8V]U;G1S+"!W;W)D3&ES=" I.PT*(" (" (" (&EN5V]R9" ](&9A;'-E M.PT*(" (" (" (&-U<G)E;G17;W)D(#T M<G5E("D +R\ :&%P<&5N<R!I9B!W;W)D(&-H87( 9F]U;F0 :G5S="!B969O M8VAA<B!C("D-"GL-"B <F5T=7)N("AC(#X]("=A)R F)B!C(#P]("=Z)RD M?'P *&, /CT )T$G("8F(&, /#T M;W5N=$QI<W0 =V]R9$QI<W0 *0T*>PT*(" O+W-T<FEN9R!;72!K97ES(#T M=V]R9$QI<W0N:V5Y<SL-"B +R]S=')I;F< =R ]('1O;&]W97(H('=O<F0 M<F1,:7-T6R!W;W)D(%TK*SL-"B ("!C;W5N=',N=V]R9', *ST ,3L-"B M"G9O:60 <')I;G17;W)D3&ES=" =V]R9$-O=6YT3&ES="!W;W)D3&ES=" I M(%M=('9A;'5E<R ]('=O<F1,:7-T+G9A;'5E<SL-" T*("!I;G0 8V]M<&%R M("AV:2 \('9J*2 _("TQ(#H *'9I(#T M=&UP26YT(#T M97-;(&H 73L-"B ("!V86QU97-;(&H 72 ]('1M<$EN=#L-"B ("!S=')I M;F< =&UP4W1R(#T :V5Y<UL :2!=.PT*(" (&ME>7-;(&D 72 ](&ME>7-; M(%%3;W)T*"DI+G-O<G0H(&ME>7,N;&5N9W1H+"!C;VUP87)E+"!S=V%P("D[ M+2TM+2T ("TM+2U<;B( *3L-"B 9F]R(" :6YT(&D /2 P.R!I(#P :V5Y ` end begin 666 Sort.d M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+0T*(" O+R!A8G-T<F%C="!B M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+0T*8VQA<W, M("!U:6YT('-I>F4 /2!T:&ES+G-I>F4H*3L-"B ("!I9B H('-I>F4 /B Q M*3L-" T*("!P<F]T96-T960 86)S=')A8W0 :6YT(&-O;7!A<F4H('5I;G0 M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+2TM+0T*(" O+R!C;&%S<R!T;R!S;W)T(&]B:F5C=', ;V8 M87)B:71R87)Y(&-O;7!L97AI='D-"B +R\ +2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M(" =6EN="!S:7IE+" (" (" (" (" (" (" (" (" ("\O(&YU M;6)E<B!O9B!D871A(&ET96US('1O('-O<G0-"B ("!I;G0 (&1E;&5G871E M*"!U:6YT+"!U:6YT("D 8V]M<&%R92P +R\ 9G5N8W1I;VX =&\ 8V]M<&%R M92!T=V\ 9&%T82!I=&5M<PT*(" ('9O:60 9&5L96=A=&4H('5I;G0L('5I M;G0 *2!S=V%P("D (" O+R!F=6YC=&EO;B!T;R!S=V%P('1W;R!D871A(&ET M871I8R!V;VED('%S;W)T*"!U:6YT(' L('5I;G0 <BP-"B :6YT("!D96QE M('5I;G0L('5I;G0 *2!S=V%P("D-"GL-"B :68 *"!P(#P M>PT*(" ('5I;G0 <2 ](%-O<G0N<&%R=&ET:6]N*"!P+"!R+"!C;VUP87)E M<" I.PT*(" (%-O<G0N<7-O<G0H('$ *R Q+"!R+"!C;VUP87)E+"!S=V%P M:6]N*"!U:6YT(' L('5I;G0 <BP-"B :6YT("!D96QE9V%T92 =6EN="P M*2!S=V%P("D-"GL-"B =6EN="!I(#T M8V]M<&%R92 :2P <" I(#T M;FET=&5S= T*>PT*("!P<FEN=&8H(")<;E1E<VEN9R!C;&%S<R!14V]R=$)A M9&%T83L-"B ("!T:&ES*"D-"B (" ('L-"B (" ('1H:7,N9&%T85L M,"!=(#T M(" <'5B;&EC(&]V97)R:61E('9O:60 <F5V97)S92 I('L =&AI<RYD871A M+G)E=F5R<V4[('T-"B ("!P=6)L:6, ;W9E<G)I9&4 =6EN="!S:7IE*"D M>R!R971U<FX =&AI<RYD871A+FQE;F=T:#L ?0T*(" ('!R;W1E8W1E9"!O M=F5R<FED92!I;G0 8V]M<&%R92 =6EN="!I+"!U:6YT(&H *0T*(" (" M>PT*(" (" 8VAA<B!;72!V:2 ]('1H:7,N9&%T85L :2!=.PT*(" (" M8VAA<B!;72!V:B ]('1H:7,N9&%T85L :B!=.PT*(" (" <F5T=7)N("AV M(" ('!R;W1E8W1E9"!O=F5R<FED92!V;VED('-W87 H('5I;G0 :2P =6EN M="!J("D-"B (" ('L-"B (" (&-H87( 6UT =&UP26YT(#T =&AI<RYD M<B H(&EN="!I(#T ,#L :2 \('0N<VEZ92 I.R!I*RL *0T*(" ('!R:6YT M<&]R="!C+G-T9&EO.PT*("!P<FEN=&8H(")<;E1E<VEN9R!C;&%S<R!14V]R M=%QN+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2U<;B( *3L-"B <W1A=&EC M(&-H87);75LV72!D871A(#T 6R B1F]X=')O="(L(")!;'!H82(L(")$;V<B M92 =6EN="!I+"!U:6YT(&H *0T*(" ('L-"B ("!C:&%R(%M=(&1I(#T M(" (&-H87( 6UT =&UP26YT(#T 9&%T85L :2!=.PT*(" (&1A=&%;(&D M?0T*("!14V]R="!Q<R ](&YE=R!14V]R=" I.PT*("!Q<RYS;W)T*"!D871A M(&D /"!D871A+FQE;F=T:#L :2LK("D-"B ("!P<FEN=&8H(&1A=&%;(&D 272!^(")<;B( *3L-"GT-" T* ` end
Jul 29 2003