Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Extra whitespace to put the `cond` clauses in columns can make it even more clear, for "visual" looking at code, rather than only "verbal":

    (define (member? item set)
      (cond ((null? set)             #f)
            ((equal? item (car set)) #t)
            (else                    (member? item (cdr set)))))
For bonus points, line up the key variable in the clauses, and it's easier to see visually that the `cond` is about that one variable:

    (define (member? item set)
      (cond ((null?       set)       #f)
            ((equal? (car set) item) #t)
            (else                    (member? item (cdr set)))))
Which accidentally also lines up with one of the procedure's arguments, though I didn't intend that one, but you could double down on that:

    (define (member? item      set)
      (cond ((null?            set)  #f)
            ((equal? item (car set)) #t)
            (else                    (member? item (cdr set)))))
This isn't some deep thing; just a little example of how sometimes whitespace, other than just indenting at the beginning of the line, helps to exposure some of the structure visually.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: