Mercurial > projects > dstress
comparison run/i/interpret_01_B.d @ 1418:5cc974ee1e2f
Re: Compile time function execution...
Lionello Lunesu <lio@lunesu.remove.com>
2007-02-16
http://www.digitalmars.com/webnews/newsgroups.php?group=digitalmars.D&article_id=48917
author | thomask |
---|---|
date | Sun, 11 Mar 2007 11:17:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1417:b9844b283021 | 1418:5cc974ee1e2f |
---|---|
1 // $HeadURL$ | |
2 // $Date$ | |
3 // $Author$ | |
4 | |
5 // @author@ Lionello Lunesu <lio@lunesu.remove.com> | |
6 // @date@ 2007-02-16 | |
7 // @uri@ http://www.digitalmars.com/webnews/newsgroups.php?group=digitalmars.D&article_id=48917 | |
8 // @desc@ Re: Compile time function execution... | |
9 | |
10 module dstress.run.i.interpret_01_B; | |
11 | |
12 template eval(A...) { | |
13 alias A eval; | |
14 } | |
15 | |
16 char[] trimfirst(char[] s){ | |
17 int x = 0; | |
18 foreach (char each; s) { | |
19 if (each != ' '){ | |
20 return s[x .. $]; | |
21 } | |
22 x++; | |
23 } | |
24 return s; | |
25 } | |
26 | |
27 int main(){ | |
28 char[] a = eval!(trimfirst(" test"))[0]; | |
29 if(a != "test"){ | |
30 assert(0); | |
31 } | |
32 return 0; | |
33 } |