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

Why aren't you programming in LISP`?`?`

Name: Gagrid 2013-05-10 17:23


The expert ``programmer'' language.

C code to print from 1 to 10

import stdio.h

int main(){
  for (int i=1; i<=10; i++) {
    printf(yada yada);
  }
}





LISP


(loop for i from 1 to 10 do (print x))

Name: Anonymous 2013-05-11 22:46

>>30,33,34
fixed point.

I would have done >>18 with named let.


(let asdf ((x 1))
  (display x)
  (if (< x 10)
    (asdf (+ x 1))))


if you wanted to avoid recursive definition:


(define asdf (lambda (f x)
               (display x)
               (if (< x 10)
                 (f f (+ x 1)))))

(asdf asdf 1)


if you wanted to avoid recursive definition with style:


(define fix_ (lambda (f g)
  (lambda args
    (apply g (cons (f f g) args)))))

(define fix (lambda (f)
  (fix_ fix_ f)))

(define asdf (fix (lambda (f x)
                    (display x)
                    (if (< x 10)
                      (f (+ x 1))))))

(asdf 1)

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