Lecture overview -- Keyboard shortcut: 'u'  Previous page: Tail Calls -- Keyboard shortcut: 'p'  Next page: Examples of recursion: string-merge -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 5 : 35
Programming Paradigms
Recursion and Higher-order Functions
Example of recursion: number-interval

The function number-interval returns a list of integers from a lower bound to an upper bound

(define (number-interval f t)
 (if (<= f t)
     (cons f (number-interval (+ f 1) t))
     '()))

The function number-interval from the general LAML library. This function returns a list of t-f+1 numbers from f to t .Try it out!.

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/number-interval.scmThe function number-interval-iter is an iterative, tail recursive variant of number-interval.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/number-interval-dialogueA sample dialogue with the number interval functions.


Go to exerciseThe append function
Go to exerciseA list replication function