tags:
- lecture
- notes
- bsu
- school
- cs354
- programming-languages
- scheme
source: https://boisestatecanvas.instructure.com/courses/37064/files/folder/pub/slides?preview=18263169
created: 2025-01-15
published: 2025-01-13
When was the original Lisp designed?
The original Lisp was designed in 1958.
Who designed the original Lisp?
The original Lisp was designed by John McCarthy.
What are the two main dialects of the original Lisp?
The two main dialects of the original Lisp are:
What is the only other programming language which is older than the original Lisp and by how long?
The only other programming language which is older than the original Lisp is Fortran by one year.
Has Fortran changed drastically?
Yes, Fortran has changed drastically.Has Lisp changed drastically?
No, Lisp hasn't changed drastically.
What paradigm is the pure subset of Lisp?
The pure subset of Lisp is functional.
What is the pure subset of Lisp based on?
The pure subset of Lisp is based on the lambda calculus of Alonzo Church.
Those who cannot remember the past are condemned to repeat it.
Those who don't know Lisp are doomed to ... ..., ...
Those who don't know Lisp are doomed to reinvent it, poorly.
What are the features of Scheme?
The features of Scheme include:
# PATH=/bin:/usr/bin LD_LIBRARY_PATH= make
all:
echo $(addsuffix .class,$(basename $(wildcard *.java)))
$(guile (let ((msg (list "Hello " "world\n"))) \
(display (car msg)) \
(display (cadr msg))))
What is a Scheme program made up of?
A Scheme program is made up of a set of function definitions followed by a sequence of function calls.
What is the function definition syntax in Java?
The function definition syntax in Java is:
What is the function definition syntax in Scheme?
The function definition syntax in Scheme is:
What is the function call syntax in Java?
The function call syntax in Java is:
What is the function call syntax in Scheme?
The function call syntax in Scheme is:
What does an open parenthesis always mean in Scheme?
In Scheme, an open parenthesis always means you're calling a function.
;; Scheme sum program
(define (sum seq)
(if (null? seq)
0
(+ (car seq) (sum (cdr seq)))))
(display (sum '(5 6 1 8 3 7)))
(display "\n")
What does the abbreviation 'x
mean?
The abbreviation 'x
means (quote x)
.
What does the abbreviation
'(...)
mean?
The abbreviation'(...)
means(quote (...))
.
What does the built-in function quote
return?
The built-in function quote
returns its one parameter, unevaluated.
What is a function definition in Scheme?
In Scheme, a function definition is a call to a function called define
which defines a function.
;; Scheme sum program
(define (sum seq)
(define (sum seq res)
(if (null? seq)
res
(sum (cdr seq) (+ res (car seq)))))
(sum seq 0))
(display (sum '(5 6 1 8 3 7)))
(display "\n")
What does the built-in function car
do?
The built-in function car
returns the first value in a sequence.
What does the built-in function cdr
do?
The built-in function cdr
returns all of the values in a sequence except the first.
What can a translator or compiler do if it recognizes a tail recursive function?
If a translator or compiler recognizes a tail recursive function, it can optimize the translated or compiled code by utilizing jump instructions.
Does the define
function cause a side effect?
Yes, the define
function causes a side effect.
Can the define
function redefine a symbol?
Yes, the define
function can redefine a symbol.
Is the define
function an imperative feature and when?
Yes, the define
function is an imperative feature if misused.
What makes a function definition and a variable definition similar in Scheme?
In Scheme, a function definition and a variable definition are similar in that both simply bind a value to a symbol (its name).
What makes a function definition and a variable definition dissimilar in Scheme?
In Scheme, a function definition and a variable definition are dissimilar in that the type of the value is different.
How do you denote a callable value in Scheme?
In Scheme, you denote a callable value with (lambda ...)
.
define
function, calling it, and displaying itguile> (define (f x) (+ 1 x))
guile> (f 123)
$1 = 124
guile> f
$2 = #<procedure f (x)>
+
functionguile> (define f (+ 1 123))
guile> f
$1 = 124
lambda
functionguile> (define f (lambda (x) (+ 1 x)))
guile> (f 123)
$1 = 124
guile> f
$2 = #<procedure f (x)>
lambda
function without giving it a nameguile> ((lambda (x) (+ 1 x)) 123)
$1 = 124
...
What does a Scheme program consist of?
A Scheme program consists of symbolic expressions called S-expressions.
What does a literal evaluate itself to?
A literal evaluates itself to itself.
What does a symbol evaluate to/
A symbol evaluates to its defined value.
What does a paranthesized sequence of S-expressions evaluate to?
A paranthesized sequence of S-expressions evaluates to the return value of first S-expression in the sequence being called as a function and the remaining S-expressions being passed to that function as parameters.
How are some parameters to some functions evaluated?
Some parameters to some functions are evaluated after the function call.
...
...