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

Great programmers

Name: Anonymous 2011-09-18 7:43

The difference between a tolerable programmer and a great programmer is not how many programming languages they know, and it's not whether they prefer Python or Java or anything that isn't Lisp. It's whether they can communicate their ideas. By persuading other people, they get leverage. By writing clear comments and technical specs, they let other programmers understand their code, which means other programmers can use and work with their code instead of rewriting it. Absent this, their code is worthless.

Name: Anonymous 2011-09-18 20:45

>>14
I never did read SICP or program in Scheme, is this tail-recursive?

#include <stdlib.h>
#include <stdio.h>

#define lambda(type, ...)            \
  ({                        \
    type (*__lambda_fptr)(__VA_ARGS__);        \
    type __lambda(__VA_ARGS__)

#define lambda_end                \
      __lambda_fptr = __lambda;            \
  })

typedef unsigned long long int fact_t;
#define PRIFACT_T "%llu\n"
typedef fact_t (*factfun) (fact_t, fact_t);

fact_t factorial (fact_t n) {
  factfun lp = lambda (fact_t, fact_t m, fact_t acc) {
    return m ? lp (m-1, m*acc) : acc;
  } lambda_end;

  return lp (n, 1);
}

int main (int argc, char ** argv) {
  printf (PRIFACT_T, factorial (--argc ? atoi (*++argv) : 0));

  return 0;
}

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