Re: Experiment: functional concepts in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Carmody

    Re: Experiment: functional concepts in C

    Ertugrul Söylemez <es@ertes.dewri tes:
    Hello people,
    >
    I thought it would be funny to try to bring functional concepts into the
    C language. If anyone is interested, I have published the results on my
    blog [1].
    >
    [1] http://blog.ertes.de/2008/11/obscure...rspective.html
    "I have written four versions of the factorial function in C
    [...]
    Version 2 — using function pointer continuations"

    [ which contains:
    void fact(int x, void (*e)(char *), void (*k)(int)) {
    void mulCont(int y) {
    k(x*y);
    }
    ... ]

    Version 3 — implementing algebraic lists and folds using closures

    [ which contains:
    void cons(int x, list xs, void (*k)(list)) {
    void concat(void (*end)(), void (*more)(int)) {
    more(x);
    xs(end, more);
    }
    ... ]

    Version 4 — lambda calculus with fixpoint operator

    [ which contains:
    void fix(int (*f)(int (*)(int), int), void (*k)(int (*)(int))) {
    int ldf(int x) {
    int y;
    ... ]
    """


    Perhaps you'd like to reword the introduction to say "I have written
    four versions of the factorial function, one of which is in C and
    the rest of them are not in C."?

    Phil
    --
    I tried the Vista speech recognition by running the tutorial. I was
    amazed, it was awesome, recognised every word I said. Then I said the
    wrong word ... and it typed the right one. It was actually just
    detecting a sound and printing the expected word! -- pbhj on /.
Working...