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

FORCE INDENTATION OF LISP

Name: Anonymous 2007-07-20 11:02 ID:a6DFnjq5

define
  is-prime x
  "Tests if x is prime using the Sieve of Eratosthenes"


    define
      divides? n primes
      "Does n divide with any of the primes?"

      if (not (eq? primes '())
        if (not (= (modulo n (car primes)) 0))
          divides? n (cdr primes)     
          #t                              
        #f                            


    define
      iter x n primes
      "Does n divide with any of the primes?"

      if (<= n x)
        if (divides? n primes) 
          if (= n x)                         
            #f                           
            iter x (+ n 2) primes                
          iter x
            + n 2                          
            append primes (list n)        
        #t                                

        if (not (= 0 (modulo x 2)))        
           iter x 3 '()                   
           #f

Name: Anonymous 2007-07-20 11:15 ID:a6DFnjq5

The fact is, indentation of Lisp code happens anyway with pretty printing, and implies where the parans should be anyway. The parans are superfluous in light of that.

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