digitalmars.D - OT: What's your favorite codeline?
- A Bothe (6/6) Aug 29 2009 What's your favorite line of D code?
- language_fan (3/9) Aug 29 2009 foreach(Problem p; World.problems) find_answer_to(p);
- Manfred_Nowak (2/5) Aug 29 2009 ... because it doesn't have `World.plan' to its disposal.
- Jeremie Pelletier (2/9) Aug 29 2009 You are lacking a world context, cultural semantics, a problem solver, a...
- Ary Borenszweig (4/8) Aug 29 2009 Isn't that C#? :-)
- language_fan (3/13) Aug 29 2009 I've heard a d guru known as 'downs' is the master of obfuscated one-
- downs (12/26) Aug 30 2009 Well I wouldn't call myself a 'guru' .. 'mutilator', mebbe :)
- Robert Fraser (5/7) Sep 01 2009 Heh, I love that infix expression syntax. Too abd it ends up with a
- downs (8/21) Sep 02 2009 I'm 90% sure it can.
- language_fan (9/39) Sep 02 2009 This is impressive. You acknowledge that the functional representation i...
- Tom S (12/13) Aug 30 2009 I like my recent:
What's your favorite line of D code? My one is Application.Run(); And yours? ------------------------------------------------------------------------------ PS: Check out my D-IDE at http://www.alexanderbothe.com/?id=27
Aug 29 2009
Sat, 29 Aug 2009 11:14:15 -0400, A Bothe thusly wrote:What's your favorite line of D code? My one is Application.Run(); And yours?foreach(Problem p; World.problems) find_answer_to(p); It just always seems to get stuck.
Aug 29 2009
incognito wrote:foreach(Problem p; World.problems) find_answer_to(p); It just always seems to get stuck.... because it doesn't have `World.plan' to its disposal.
Aug 29 2009
Manfred_Nowak Wrote:incognito wrote:You are lacking a world context, cultural semantics, a problem solver, and a very very large pool of random. Maybe an abstract country factory.foreach(Problem p; World.problems) find_answer_to(p); It just always seems to get stuck.... because it doesn't have `World.plan' to its disposal.
Aug 29 2009
A Bothe escribió:What's your favorite line of D code? My one is Application.Run();I think a favorite line of D code should have a feature of D that doesn't appear in any other language...
Aug 29 2009
Sat, 29 Aug 2009 13:45:23 -0300, Ary Borenszweig thusly wrote:A Bothe escribió:I've heard a d guru known as 'downs' is the master of obfuscated one- liners.What's your favorite line of D code? My one is Application.Run();I think a favorite line of D code should have a feature of D that doesn't appear in any other language...
Aug 29 2009
language_fan wrote:Sat, 29 Aug 2009 13:45:23 -0300, Ary Borenszweig thusly wrote:Well I wouldn't call myself a 'guru' .. 'mutilator', mebbe :) That being said, here's the results of a quick grep of my #d log for memorable lines <downs> Bignum!(To - From)* slice(int From, int To)() { return cast(Bignum!(To - From)*) ((cast(Type*) this) + From); } <downs> struct ZipIterator(A, B) { A a; B b; int length() { return min(a.length, b.length); } Stuple!(typeof(a[0]), typeof(b[0])) opIndex(T...)(T t) { return stuple(a[t], b[t]); } int opApply(C)(C callable) { for (int x = 0; x < length; ++x) { static if (is(typeof(callable(x, a[x], b[x])))) { if (auto res = callable(x, a[x], b[x])) return res; } else { if (auto res = callable(a[x], b[x])) return res; } } return 0; } } <downs> class Lévy : LSystem!(8) { <downs> mixin(LSysFunc("X -> +X--X+ / step")); <downs> Ret!(T[$-1]) delegate(Param!(T[$-1])[T.length - 1 .. $]) bind(T...)(T params) { struct Stuff { T data; Ret!(T[$-1]) call(Param!(T[$-1])[T.length - 1 .. $] rest) { return data[$-1](data[0 .. $-1], rest); } } auto res = new Stuff; foreach (id, value; params) res.data[id] = value; return &res.call; } <downs> prettyprint(rand%640, rand%480, Center, rgb(col), Fill = rgb(hsv((col.h + 128) % 255, col.s, col.v)), Format("[size ", rand() % 12 + 8, "] Don't worry, be happy! [/size]")); <downs> foo.betweens("src=\"", "\"") /select/ (string s) { return s.find(criteria) != -1; } <downs> "/proc/cpuinfo".read().castLike("").between("cpu MHz", "\n").between(": ", "") <downs> auto videocon = ctx.getStreams().first(WHERE!("?.codec.codec_type == CodecType.Video")).codec;A Bothe escribió:I've heard a d guru known as 'downs' is the master of obfuscated one- liners.What's your favorite line of D code? My one is Application.Run();I think a favorite line of D code should have a feature of D that doesn't appear in any other language...
Aug 30 2009
downs wrote:<downs> foo.betweens("src=\"", "\"") /select/ (string s) { return s.find(criteria) != -1; }Heh, I love that infix expression syntax. Too abd it ends up with a completely useless wrapper struct & 2 function calls, but hopefully LDC can inline that out.<downs> auto videocon = ctx.getStreams().first(WHERE!("?.codec.codec_type == CodecType.Video")).codec;Heh, going LINQ on us, now?
Sep 01 2009
Robert Fraser wrote:downs wrote:I'm 90% sure it can. [update] Actually, I just tried and LDC compiles a simple /select/ test to plain, inlined code. [update2] GDC doesn't. [update3] For that matter, neither does DMD. LDC is really shaping up to be the best D compiler out there. It already is on Unix (imho). Now if only they can get win32 exception support to work ..<downs> foo.betweens("src=\"", "\"") /select/ (string s) { return s.find(criteria) != -1; }Heh, I love that infix expression syntax. Too abd it ends up with a completely useless wrapper struct & 2 function calls, but hopefully LDC can inline that out.I _was_ thinking of that :) Could have used ex!() but WHERE is a little denser. (for comparison: ex!("c -> c.codec.codec_type == CodecType.Video") )<downs> auto videocon = ctx.getStreams().first(WHERE!("?.codec.codec_type == CodecType.Video")).codec;Heh, going LINQ on us, now?
Sep 02 2009
Wed, 02 Sep 2009 10:28:58 +0200, downs thusly wrote:Robert Fraser wrote:This is impressive. You acknowledge that the functional representation is so much better that you actually implement its compiler with the metaprogramming facilities. Imagine, in future, you can just write, mixin compile("SML", ` some code ... `); and all your problems are solved. It's a shame the built-in syntax looks like this crap (T)(T c){ return c; } instead of this c -> cdowns wrote:I'm 90% sure it can. [update] Actually, I just tried and LDC compiles a simple /select/ test to plain, inlined code. [update2] GDC doesn't. [update3] For that matter, neither does DMD. LDC is really shaping up to be the best D compiler out there. It already is on Unix (imho). Now if only they can get win32 exception support to work ..<downs> foo.betweens("src=\"", "\"") /select/ (string s) { return s.find(criteria) != -1; }Heh, I love that infix expression syntax. Too abd it ends up with a completely useless wrapper struct & 2 function calls, but hopefully LDC can inline that out.I _was_ thinking of that :) Could have used ex!() but WHERE is a little denser. (for comparison: ex!("c -> c.codec.codec_type == CodecType.Video") )<downs> auto videocon = ctx.getStreams().first(WHERE!("?.codec.codec_type == CodecType.Video")).codec;Heh, going LINQ on us, now?
Sep 02 2009
A Bothe wrote:What's your favorite line of D code?I like my recent: c.resFunc = cast(void function(void*))(*cast(void***)proto.resources[origResIdx].init().ptr)[ Command.Type.ResAcquire == c.type ? 1 : 2 ]; Sure, it's 3 lines, but still one statement and if I were downs, that would *be* one line ;D -- Tomasz Stachowiak http://h3.team0xf.com/ h3/h3r3tic on #D freenode
Aug 30 2009