Bragging about Unix and D

Georg Wrede georg at nospam.org
Wed Aug 23 16:35:31 PDT 2006


I just came to town. I had an interesting debate with somebody who 
didn't appreciate Unix (or Linux) or D enough. So I showed to him that 
interacting with a Unix machine is discussing, and that when you're good 
at it, you talk with sentences, not single commands (as in DOS). He 
demanded examples, and one I gave him was to ask the machine for a 
multiplication table. I conjured up the following sentence:

$ for a in {0..9};do for b in {0..9};do echo -ne `dc -e"$a $b 
*pq"`"\011";done;echo;done

which gave a nice table:

0     0     0     0     0     0     0     0     0     0
0     1     2     3     4     5     6     7     8     9
0     2     4     6     8     10    12    14    16    18
0     3     6     9     12    15    18    21    24    27
0     4     8     12    16    20    24    28    32    36
0     5     10    15    20    25    30    35    40    45
0     6     12    18    24    30    36    42    48    54
0     7     14    21    28    35    42    49    56    63
0     8     16    24    32    40    48    56    64    72
0     9     18    27    36    45    54    63    72    81

Now, I wanted to do the same thing with DMD, but I failed miserably.

What I tried to do was some kind of template magic (a la Don) that 
prints something like this at compile time, without even creating an 
executable.

-- Sigh, can't win 'em all.



More information about the Digitalmars-d mailing list