Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

is it ok to do this

Name: Anonymous 2007-06-23 13:51 ID:6CyOAcE6

instead of

int f(a) {
if(a == 3) return 1
else return 0;
}

to write

return (a == 3);

? thanks in advance

Name: Anonymous 2007-06-26 17:19 ID:FGz2FDeC

am i doing it rite?

#include <stdio.h>
#define defun(out, n, in...)    out n (in)
#define define(type, var, val)  type var = val
#define eif(c, t, f)            ((c) ? (t) : (f))
#define eq(a, b)                ((a) == (b))
#define sub(a, b)               ((a) - (b))
#define mul(a, b)               ((a) * (b))

defun(int, fact, int x) {
    return(eif(eq(x, 0),
               1,
               mul(x, fact(sub(x, 1)))));
}

defun(int, main) {
    define(int, i, fact(5));
    printf("5! = %d\n", i);
    return(0);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List