Lecture overview -- Keyboard shortcut: 'u'  Previous page: Referential Transparency [Section] -- Keyboard shortcut: 'p'  Next page: Referential Transparency -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 47 : 49
Programming Paradigms
Introduction to Functional Programming in Scheme
Referential Transparency - Practical Aspects

We will illustrate the idea of referential transparency in the context of practical Scheme Programming

(let ((a (list 1 2))
      (b (list 1 2))
      (c (list 3 4)))
  (append a b c))            <==>

(let ((a (list 1 2))
      (c (list 3 4)))
  (append a a c))            <==>

(let ((a (list 1 2)))
  (append a a (list 3 4)))   <==>

(let ((a (list (- 3 2) 2))
      (b (list 1 (+ 1 1))))
  (append a b (list 3 4)))   <==>

(list 1 2 1 2 3 4) 

Rewriting an expression in various ways - use of referential transparency.

A copy of some data can be used as a substitute for the original data

A value of an expression can be used as a substitute for the expression itself

A 'more complicated expression' can be used as a substitute for 'the original expression'