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

editor settings

Name: Anonymous 2011-07-31 16:20

What's your tab width (4)? Do you use spaces or tabs (tabs) ? What's your text width (100)?

Name: Anonymous 2011-08-02 0:40

Functional programs have a different shape from imperative
ones. The structure in a functional program comes entirely from the composition
of arguments within expressions, and since arguments are indented, functional
code will show more variation in indentation. Functional code looks fluid 1 on the
page; imperative code looks solid and blockish, like Basic.


Example:
(defun bad-reverse (lst)
  (let* ((len (length lst))
         (ilimit (truncate (/ len 2))))
    (do ((i 0 (1+ i))
         (j (1- len) (1- j)))
        ((>= i ilimit))
      (rotatef (nth i lst) (nth j lst)))))


(defun good-reverse (lst)
  (labels ((rev (lst acc)
             (if (null lst)
                 acc
                 (rev (cdr lst) (cons (car lst) acc)))))
   (rev lst nil)))

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