CS 461
Programming Language Concepts
Gang Tan
Computer Science and Engineering Penn State University
2ND EXAM REVIEW
•1 •2
Format
Exam Time
• Apr 6th, 8-9pm US Eastern Time (60 minutes)
Canvas-based exam
• You will be shown one question at a time
• Can go forward/backward to next/previous question • IMPORTANT: you can submit your exam only once
– DO NOT PRESS the “SUBMIT QUIZ” button until you are done
Next for moving to the next question
Submit Quiz for submitting the entire exam (can be done only once)
•3 •4
Format
60-min exam
• Open book and notes
• Not allowed to communicate with other students
during the exam
• Questions during the exam can be posted to
campuswire
– make them viewable only to instructors and TAs
– phrase the question to make it easily understandable
My office hours next week moved to Monday • Monday 1:15pm to 3:15pm on Zoom
Types of Questions
True/false questions
Multiple-choice questions
Short answer questions
You will be expected to be able to read and write small Scheme programs; also expected to read programs in other languages
•5 •6
1
Ch9 Functions
Basic Terminology
• Functions, procedures, methods, subroutines • Arguments vs. parameters
Parameter passing mechanisms
• By value, by result, by value result, by ref, by name • Pass by value-result vs. pass by reference
– Alias
• Parameter passing in major languages (C, C++, Java,
Ada, …)
Implementation of functions calls and returns
• Stack of activation records
• An activation record: parameters and local variables,
return address, dynamic/static link, return value, saved
registers, …
• Support recursive functions
Ch9 Functions
Possible questions
• Figure out the result of a program if a particular
parameter passing mechanism is used
• Understand/interpret the contents in activation
records
You do not need to know
• The ordering of components in an activation record
•7 •8
Ch11 Functional Programming
Scheme
• (E1E2…En)
• (define name value)
– can be a function value (lambda (x) …) • Anonymous functions
• (ifPE1E2)
• (cond (P1 E1) … (Pn En)
(else En+1))
• (let ((x1 E1) (x2 E2) … (xk Ek)) E)
• (let* ((x1 E1) (x2 E2) … (xk Ek)) E)
• (letrec ((x1 E1) (x2 E2) … (xk Ek)) E) • High-order functions
Ch11 Functional Programming
Scheme, cont’d
• List processing: null?, car, cdr, cons
• Manipulating lists: length, map, reduce, …
– case analysis and recursion • Association lists
• Currying/uncurrying
Possible questions • Scheme
– Programming questions
– Pay attention to parentheses!
– Don’t forget the empty-list case
•9 •10
2