Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For instance, the finding the largest element in a list follows only the first general template:

Code Block
(define (get_largest lon)
  (cond
    [(empty? lon) (error "no largest in an empty list")]
    [(cons? lon)
     (local
       [(define (helper acc lon2)
          (cond
            [(empty? lon2) acc]
            [(cons? lon2) (helper (if (> (first lon2) acc) (first lon2) acc) (rest lon2))]))]
       (helper (first lon) (rest lon)))]))   

...