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

ITT the ABC Programming Language

Name: Anonymous 2008-07-29 19:29

#include <stdio.h>

int main(int argc,char argv*[]){
  int i = 0;
  int BUFFA;

  while(argv[i]!='\0'){
    if(argv[i]='a')
      BUFFA++;
    else if(argv[i]='b')
      BUFFA--;
    else if(argv[i]='c')
      printf("%i\n",BUFFA);
    else printf("%s","Error.\n");
  }
}

Name: Anonymous 2008-08-01 21:53

A vision from The Sussman came to me, and he told me what I was doing was Good but that I could do Better.  May he enjoy this RevisedThe Second The ABC Programming Language Algorithmic Implementation:
(define (abc source)
  (define accumulator 0)
  (define ascii #f)
  (define (interpret i)
    (case i
      ((#\a) (set! accumulator (+ 1 accumulator)))
      ((#\b) (set! accumulator (- accumulator 1)))
      ((#\c) (display (if ascii
                          (integer->char accumulator)
                          accumulator)))
      ((#\d) (set! accumulator (- accumulator)))
      ((#\r) (set! accumulator (random accumulator)))
      ((#\n) (set! accumulator 0))
      ((#\$) (set! ascii (not ascii)))
      ((#\l) (run))
      ((#\;) (display accumulator)
             (display (integer->char accumulator)))))
  (define (run)
    (for-each interpret (map char-downcase (string->list source)))
    (newline))
  (run))

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