mpr is currently certified at Journeyer level.

Name: Mauro Persano
Member since: 2001-12-12 11:50:15
Last Login: N/A

FOAF RDF Share This

Homepage: http://superglue.se/~fuse

Recent blog entries by mpr

Syndication: RSS 2.0
17 Sep 2004 (updated 17 Sep 2004 at 17:34 UTC) »

You know how C++ programmers are always bragging about how you can do things like compute factorials at run-time with templates? Well, C++'s template system is nothing but a glorified preprocessor, and here's evidence. Try it with something like gcc -w -DN=11 fact.c -o fact.

#ifndef INITIALIZED
    #define INITIALIZED
    #ifndef N
        #define N 11
    #endif
    #define A ((N)&1)
    #define B ((N)>>1&1)
    #define C ((N)>>2&1)
    #define D ((N)>>3&1)
int
main(void)
{
    printf("fact(%d) = %d", N,
    #include __FILE__
    );
}
#else /* INITIALIZED */
    (8*D + 4*C + 2*B + A)
    #if A
        #define A 0
    #else
        #define A 1
        #if B
            #define B 0
        #else
            #define B 1
            #if C
                #define C 0
            #else
                #define C 1
                #if D
                    #define D 0
                #endif
            #endif
        #endif
    #endif
    #if A || B || C || D
        *
        #include __FILE__
    #endif
#endif

Credit where credit is due: the idea comes from the IOCCC entry that does Towers of Hanoi with the preprocessor.

For our next example, we'll show how you can generate code for a 256-point FFT with the preprocessor.

(to be continued)

 

mpr certified others as follows:

  • mpr certified pabs3 as Apprentice
  • mpr certified sdodji as Journeyer
  • mpr certified sye as Apprentice
  • mpr certified fxn as Journeyer
  • mpr certified lev as Journeyer
  • mpr certified Liedra as Apprentice
  • mpr certified Zaitcev as Master
  • mpr certified madhatter as Apprentice
  • mpr certified redi as Journeyer
  • mpr certified mbrubeck as Journeyer
  • mpr certified chakie as Journeyer
  • mpr certified brejc8 as Journeyer
  • mpr certified sfllaw as Apprentice
  • mpr certified Svartalf as Journeyer
  • mpr certified imbe as Journeyer
  • mpr certified lerdsuwa as Journeyer
  • mpr certified lloydwood as Journeyer
  • mpr certified Jordi as Journeyer
  • mpr certified graham as Journeyer
  • mpr certified bonzini as Master
  • mpr certified helcio as Journeyer
  • mpr certified richdawe as Master
  • mpr certified Jody as Master
  • mpr certified elanthis as Apprentice
  • mpr certified nymia as Apprentice
  • mpr certified cm as Journeyer
  • mpr certified sarum as Journeyer
  • mpr certified berend as Journeyer
  • mpr certified rasmus as Master
  • mpr certified Pizza as Journeyer
  • mpr certified ncm as Master
  • mpr certified jolan as Journeyer
  • mpr certified Akira as Journeyer
  • mpr certified wingo as Journeyer
  • mpr certified acs as Apprentice
  • mpr certified mibus as Apprentice
  • mpr certified slamb as Journeyer
  • mpr certified haruspex as Journeyer
  • mpr certified werner as Master
  • mpr certified ffxz as Journeyer
  • mpr certified goingware as Journeyer
  • mpr certified bluefoxicy as Apprentice
  • mpr certified xanth as Journeyer
  • mpr certified lucasgonze as Journeyer
  • mpr certified mathieu as Master
  • mpr certified brouhaha as Journeyer
  • mpr certified azz as Journeyer
  • mpr certified Guillaume as Master
  • mpr certified mchang as Journeyer
  • mpr certified dangermaus as Journeyer
  • mpr certified neoneye as Journeyer
  • mpr certified murrayc as Master
  • mpr certified daverd as Journeyer
  • mpr certified armin as Journeyer
  • mpr certified loadquo as Apprentice
  • mpr certified Spooky as Journeyer
  • mpr certified Monty as Journeyer
  • mpr certified redhog as Journeyer
  • mpr certified pnasrat as Journeyer
  • mpr certified Abigail as Journeyer
  • mpr certified dmuz as Journeyer
  • mpr certified pasky as Master
  • mpr certified bcc as Apprentice
  • mpr certified dln as Apprentice
  • mpr certified kz as Apprentice
  • mpr certified psychogenic as Apprentice
  • mpr certified mterry as Apprentice
  • mpr certified dmcc as Apprentice
  • mpr certified cstross as Journeyer
  • mpr certified davidz as Journeyer
  • mpr certified rmathew as Journeyer
  • mpr certified bugbiter as Journeyer
  • mpr certified skx as Journeyer
  • mpr certified RickMuller as Journeyer
  • mpr certified polak as Journeyer
  • mpr certified tmorgan as Journeyer
  • mpr certified spot as Journeyer
  • mpr certified Bram as Master
  • mpr certified rengolin as Apprentice
  • mpr certified davem as Master
  • mpr certified davidu as Apprentice
  • mpr certified hubicka as Master
  • mpr certified invoke as Apprentice
  • mpr certified aldo as Journeyer
  • mpr certified nicku as Apprentice

Others have certified mpr as follows:

  • fxn certified mpr as Journeyer
  • sdodji certified mpr as Apprentice
  • lev certified mpr as Journeyer
  • madhatter certified mpr as Journeyer
  • dmuz certified mpr as Master
  • kilmo certified mpr as Journeyer
  • rengolin certified mpr as Journeyer
  • imbe certified mpr as Journeyer
  • Guillaume certified mpr as Journeyer
  • xanth certified mpr as Apprentice
  • helcio certified mpr as Apprentice
  • richdawe certified mpr as Journeyer
  • bonzini certified mpr as Apprentice
  • elanthis certified mpr as Apprentice
  • lerdsuwa certified mpr as Apprentice
  • jolan certified mpr as Journeyer
  • lucasgonze certified mpr as Apprentice
  • polak certified mpr as Apprentice
  • domi certified mpr as Journeyer
  • acs certified mpr as Journeyer
  • dangermaus certified mpr as Master
  • cm certified mpr as Apprentice
  • pasky certified mpr as Apprentice
  • mterry certified mpr as Apprentice
  • daverd certified mpr as Apprentice
  • feztbrus certified mpr as Apprentice
  • badvogato certified mpr as Journeyer
  • dlc certified mpr as Apprentice
  • ataridatacenter certified mpr as Apprentice
  • don certified mpr as Journeyer
  • Xero certified mpr as Journeyer

[ Certification disabled because you're not logged in. ]

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!

X
Share this page