Programming Paradigms, Fall 06
|
|
- Fay Norton
- 6 years ago
- Views:
Transcription
1 Programming Paradigms, Fall 06 Multiple Choice Exam January 29, 2007, 10:00 11:15 ID Name Each of the following questions has exactly one correct answer. For each question, you may select one or more answers by marking the corresponding boxes. This means: if you are certain which answer is correct, mark just that one; if you are in doubt, mark those answers you think may be correct; if you have no idea, don t mark any answers at all. The answers are graded such that random guessing will yield a score of zero. We use the convention that x means a selected choice, and both and mean not selected.
2 Question 1 Aspect-oriented software is commonly divided into base code and aspect code, and obliviousness describes their relation. Which relation is it? 36 a x Obliviousness is a property of the language design which allows base code to be indep dent of the corresponding aspect code. 6 b Obliviousness is a property of the language design which allows aspect code to be in pendent of the corresponding base code. 15 c Obliviousness is a property of good program design which allows aspect code and corresponding base code to be independent. d Obliviousness refers to the fact that base code and the corresponding aspect code can be in the same file. Question 2 In connection with aspect-oriented languages, what is the meaning of the concept of quantification? applied at that location, thereby associating the base code with a cross-cutting subset o most specific, when advice from more than one aspect is associated with the same join 29 a x Quantification is the ability of constructs like pointcut to specify a set of different loca tions, thereby associating advice with a cross-cutting subset of the base code. 2 b Quantification is the ability to specify in base code that several pieces of advice must be the aspect code. 11 c Quantification is the ability to specify that a piece of advice should be executed only under some extra conditions when a given location in base code is reached. 9 d Quantification is the process whereby it is determined which aspect should be considered point.
3 Question 3 Explain the effect of including the AspectJ aspect AccountAspect into a program that contains the class Account: class Account { private int balance = 0; public void deposit(int amount) { balance += amount; } } aspect AccountAspect { private int counter = 0; pointcut pc(): execution(void Account.deposit(int)); after(): pc() { counter++; } } 37 a x Whenever deposit is called on some Account object, counter is incremented. Ther one global counter. 23 b Whenever deposit is called on some Account object, counter is incremented. Ther a counter for each Account. 1 c Whenever a new Account object is created, an instance of the pointcut pc is attache the new object, and counter keeps track of how often this has occurred. d It becomes possible to call the method pc on instances of Account, as well as the meth this class had before. This will increment the counter and also execute deposit. Question 4 One of the predefined kinds of pointcut in AspectJ is called cflow. Explain how it works. 26 a x It is a pointcut that takes another pointcut, say pc2, as an argument. It is enabled at a join point if and only if a join point of pc2 has been entered and not yet exited, typically because pc2 is enabled at the execution of a direct or indirect caller of the current method. 11 b It is a pointcut that takes another pointcut, say pc2, as an argument. It is enabled at a join point if and only if a join point of pc2 is about to occur, typically because pc2 is enabled at executions of a method and that method will be called next. 5 c It is a pointcut that takes a method as an argument. It is enabled at a join point if and only if that method is on the current call stack. 4 d It is a pointcut that takes a method as an argument. It is enabled at a join point if and only if that method is about to be called.
4 Question 5 What is the result of evaluating the following Haskell program? let y (q:w) = y w ++ q y _ = "@" in y ["a","b","c"] 28 a x "@cba" 9 b "abc@" 5 c "a@b@c" 5 d "abc" 3 e "cba" 14 f a type error Question 6 Consider the following Haskell definitions: data Expr a = Const a Op (Expr a) (Expr a) eval (Const c) f = c eval (Node x y) f = eval x `f` eval y What type does Haskell infer for the function eval? 12 a x eval :: Expr a -> (a -> a -> a) -> a 10 b eval :: Expr a -> a -> a 3 c eval :: (a,a) -> a 10 d eval :: (a -> a) -> a 11 e eval :: Expr a => a -> a -> a 11 f eval :: Expr a => (a -> a) -> a Question 7 What does it mean that Haskell is a pure functional programming language? 38 a x Evaluation of expressions has no side-effects. 1 b It is not being used in industry. 3 c The type checker catches all errors at compile-time. 12 d The language has higher-order, first-class functions.
5 Question 8 Which language construct in Java most closely corresponds to the notion of type classes in Haskell? 21 a x Interfaces. 10 b Classes. 15 c Generics. 2 d Packages. 6 e Inheritance. Question 9 What does it mean that the Haskell function map (as defined in the standard prelude) is polymorphic? 44 a x Its arguments can have many different types. 2 b It works on lists of any size. 9 c It has several possible definitions. 3 d It has a principal type. Question 10 Consider the simple Haskell expression f x. How is this expression evaluated? 31 a x First f is evaluated, then later x is perhaps evaluated. 9 b Both f and x are always evaluated. 8 c First x is evaluated, then later f is perhaps evaluated. 5 d It makes no difference in Haskell, so the implementation may decide. Question 11 What does the following Haskell type mean? larger :: Int -> Int -> Int 26 a x larger is a function that takes an integer as argument and returns another function that takes another integer argument and returns an integer result. 18 b larger is a function that takes a pair of integers as argument and returns an integer result. 6 c larger is a function that takes a function from integer to integer as argument and returns an integer result.
6 Question 12 Assume that we in Haskell want to define the common function composition operator, written.. Which of the following definitions is correct? 20 a x f. g = \x -> f (g x) 5 b f. g = let \x -> g in f x 4 c (.) f g = f(g(.)) 3 d f(g(x)) = \x -> f g x 17 e (.) f g = f(g) Question 13 Consider the following Haskell definition: class Eq a where (==) :: a -> a -> Bool instance Eq Integer where x == y = x `integereq ` y Which of the following statements is wrong? 34 a x == is a type class for integers. 3 b == is a binary operator that belongs to the type class Eq. 5 c When two integers are compared using ==, then the integereq function is evaluated. 5 d The == operator may be overloaded by other definitions. Question 14 Which declaration in the following Scala class could replace the... below without causing a compile time error? class Example { val i = 4... } 19 a x def half i = i/2 12 b def incr i = i = i+1 2 c def incr i() = (i = i+1) 1 d int half i() { return i/2; } 12 e def tostring() = "Hello, world!" 14 f def foo(i: int): String
7 Question 15 Scala supports a mechanism called traits. Which of the following characterizations is appropriate? features (e.g., methods) in a more flexible way than traditional inheritance allows 44 a x A trait is an abstract class which can be added to several classes, thus reusing th 11 b A trait is an abstract class which can be added to the same class several time providing overloaded versions of the same features (e.g., methods) in a way which flexible than traditional inheritance. c A trait is a special kind of class which is used to specify how an object is constru 4 d A trait is an abstract method which is implemented in more than one subclass. Question 16 Types like int and boolean are often called primitive, and in Java they are outside the type universe in the sense that there is no subtype relation between a primitive type and any other type. How is the situation in Scala? 17 a x Primitive types like int and boolean have both supertypes and subtypes. In addition to subtyping, primitive values can be transformed (coerced) to other primitive values, e.g., a value of type char can be assigned to a variable of type int. 17 b Primitive types like int and boolean have both supertypes and subtypes. Assignment involving primitive values is handled by polymorphism and subtyping, just like all other types. 7 c Primitive values in Scala can be transformed (coerced) to other primitive values, e.g., a value of type char can be assigned to a variable of type int. There are no subtyping relationships involving primitive types. 16 d There are no primitive types in Scala.
8 Question 17 Consider the following Scala program: class Stack[T] { var elems: List[T] = Nil def push(x: T): unit = elems = x::elems def top: T = elems.head def pop: unit = elems = elems.tail } object TestStack extends Application { val s = new Stack[int]() s.push(1); s.push(2) } Which one of the following statements is incorrect? 25 a x The invocations of the method s.push(...) are incorrect because s cannot be changed. 4 b T is a type parameter of the class Stack. 1 c The return type of top can differ in two different stacks. 22 d The type of elems must be declared explicitly because the compiler cannot infer the type argument. Question 18 Consider the following variant of the Scala class Stack which has been modified to be covariant in its type argument: class Stack[+T] { var elems: List[T] = Nil def push(x: T): unit = elems = x::elems def top: T = elems.head def pop: unit = elems = elems.tail } This class cannot be compiled as it is. Which of the following statements is incorrect? 12 a x T cannot be used as the result type in the method top. 7 b T cannot be used as the type argument of List in the type of elems. 6 c T cannot be used as an argument type in the method push. 12 d If elems is changed from a var to a val declaration then T can be used in List[T] as its type, but then new errors arise for other declarations in the class.
9 Question 19 What is the normal form of the lambda term (λxy.yx)(λa.ab)(λz.zz)? 32 a x bb 1 b a(bb) 2 c (λa.azz) 11 d It does not have a normal form. Question 20 How are call-by-name (CBN) and call-by-value (CBV) different? 38 a x CBV may loop when CBN does not. 9 b CBN may loop when CBV does not. 5 c CBN is always faster than CBV. 4 d CBV is always faster than CBN. 3 e CBN is necessary for recursive functions. Question 21 Which type constraint is not generated from the following Fun program? let f(x,y) = succ(succ(plus(x,y))) in let g(h,z) = h(z,z) in g(f,4) 9 a x [[h(z,z)]] = int 5 b [[g]] = fun([[f]],[[4]],[[g(f,4)]]) 16 c [[h]] = fun([[z]],[[z]],[[h(z,z[]]) 6 d [[plus(x,y)]] = int Question 22 Which Fun program does not contain any errors? 25 a x let f(x) = succ(first(x)) in f(pair(17,true)) 2 b let f(x) = succ(first(y)) in f(pair(17,true)) 5 c let f(x) = first(succ(x)) in f(pair(17,true)) 4 d let f(x) = succ(x) in f(pair(17,true)) 5 e let f(x) = succ(fst(x)) in f(pair(17,true)) 3 f let f(x) = succ(first(x)) in f(pair(true,17))
10 Question 23 Consider the following Prolog program: a(x). a(y). b(z). p(v) :- p(v). q(v) :- a(v), b(z). q(v) :- p(v). What sequence of responses do we get when posing the query?- q(v). and typing semi-colon (to get alternative answers) as many times as we can? 34 a x V = x, then V = y, and then the program then loops. 5 b The program immediately loops. 7 c V = x, and then the program then loops. 3 d V = x, then V = z, and then the program then loops. 4 e V = x, then V = y, then V = z, and then the program then loops. 1 f V = x, then V = z, then V = y, then V = z, and then the program then loops. Question 24 Consider the following Prolog program: child(anne, brit). child(brit, carol). descend1(x,y) :- child(x,y). descend1(x,y) :- child(x,z), descend1(z,y). descend2(x,y) :- descend2(z,y), child(x,z). descend2(x,y) :- child(x,y). What happens if we pose the queries?- descend1(anne, carol). and?- descend2(anne, carol)., respectively? 39 a x The descend1 query terminates and the descend2 query loops. 7 b The descend1 query terminates and the descend2 query terminates. 4 c The descend1 query loops and the descend2 query terminates. 3 d The descend1 query loops and the descend2 query loops.
11 Question 25 You have seen that functions are really relations with special requirements (and how a function f induces a relation R f ). Consider the following (lambda-calculus) function: sum3 = λx.λy.λz.(x + y + z) What is the signature of the relation, R sum3, induced by the function sum3? 20 a x R sum3 Z Z Z Z 22 b R sum3 Z Z Z c R sum3 Z Z 14 d R sum3 Z Question 26 Consider the following inference system (with one axiom and one rule): n n' = n+3 - n' Which mathematical relation does - describe? 23 a x The (unary) divisible-by-three relation 6 b The (unary) even relation 23 c The (binary) plus-three relation 6 d The (unary) is-greater-than-three relation 1 e The (binary) is-the-double-of relation Question 27 What does Prolog respond to the following query??- [ [], [] ] = [ [] V ]. 29 a x V = [[]] (i.e., V matches the list containing the empty list). 15 b V = [] (i.e, V matches the empty list). 10 c No (i.e, no match).
12 Question 28 What does Prolog respond to the following query??- 2*2 is a x No. 17 b Yes. 22 c Error: is/2: uninstantiated argument Question 29 What does Prolog respond to the following query??- 4 is 2*2. 38 a x Yes. 4 b No. 9 c Error: is/2: uninstantiated argument Question 30 Given the following Prolog rule: sq(y,x) :- Y is X*X. What does Prolog respond to the query?- sq(x,9).? 41 a x X = 81 4 b X = 3 12 c Error: is/2: uninstantiated argument Question 31 Given the following Prolog program: rev([], []). rev([h T], R) :- rev(t, TR), append(tr, [H], R). What does Prolog respond to the query?- rev([1,2,3], R).? 29 a x R = [3,2,1] 22 b R = [3,[2,[1]]] 5 c The program loops.
13 Question 32 Consider the Monty Python (Prolog) example: female(girl). floats(duck). sameweight(girl,duck). witch(x) :- burns(x), female(x). burns(x) :- wooden(x). wooden(x) :- floats(x). floats(x) :- sameweight(x,y), floats(y). What does Prolog respond to the query?- burns(duck).? 44 a x Yes 6 b No 1 c X = duck
CSCI-GA Final Exam
CSCI-GA 2110-003 - Final Exam Instructor: Thomas Wies Name: Sample Solution ID: You have 110 minutes time. There are 7 assignments and you can reach 110 points in total. You can solve the exercises directly
More informationHaskell Overview III (3A) Young Won Lim 10/4/16
(3A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And
More informationn n Try tutorial on front page to get started! n spring13/ n Stack Overflow!
Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!
More informationDiscussion. Type 08/12/2016. Language and Type. Type Checking Subtypes Type and Polymorphism Inheritance and Polymorphism
Type Joseph Spring Discussion Languages and Type Type Checking Subtypes Type and Inheritance and 7COM1023 Programming Paradigms 1 2 Type Type denotes the kind of values that programs can manipulate: Simple
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
More informationAdvanced Object-Oriented Languages Scala
Advanced Object-Oriented Languages Scala Programming Paradigms Department of Computer Science University of Aalborg, Denmark Erik Ernst (U. of Aarhus) Overview Purpose of using Scala Introduction syntax
More informationClasses, subclasses, subtyping
1 CSCE 314: Programming Languages Dr. Flemming Andersen Classes, subclasses, subtyping 2 3 Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationPierce Ch. 3, 8, 11, 15. Type Systems
Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using
More informationCSE 504. Expression evaluation. Expression Evaluation, Runtime Environments. One possible semantics: Problem:
Expression evaluation CSE 504 Order of evaluation For the abstract syntax tree + + 5 Expression Evaluation, Runtime Environments + + x 3 2 4 the equivalent expression is (x + 3) + (2 + 4) + 5 1 2 (. Contd
More informationApplicative, traversable, foldable
Applicative, traversable, foldable Advanced functional programming - Lecture 3 Wouter Swierstra 1 Beyond the monad So far, we have seen how monads define a common abstraction over many programming patterns.
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationAdvanced features of Functional Programming (Haskell)
Advanced features of Functional Programming (Haskell) Polymorphism and overloading January 10, 2017 Monomorphic and polymorphic types A (data) type specifies a set of values. Examples: Bool: the type of
More informationHaskell Overview II (2A) Young Won Lim 8/9/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationCh. 11: References & the Copy-Constructor. - continued -
Ch. 11: References & the Copy-Constructor - continued - const references When a reference is made const, it means that the object it refers cannot be changed through that reference - it may be changed
More informationLecture 8: Summary of Haskell course + Type Level Programming
Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell
More informationLargest Online Community of VU Students
WWW.VUPages.com http://forum.vupages.com WWW.VUTUBE.EDU.PK Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationUMBC CMSC 331 Final Exam
UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy
More informationHaskell 98 in short! CPSC 449 Principles of Programming Languages
Haskell 98 in short! n Syntax and type inferencing similar to ML! n Strongly typed! n Allows for pattern matching in definitions! n Uses lazy evaluation" F definition of infinite lists possible! n Has
More informationCSE 505. Lecture #9. October 1, Lambda Calculus. Recursion and Fixed-points. Typed Lambda Calculi. Least Fixed Point
Lambda Calculus CSE 505 Lecture #9 October 1, 2012 Expr ::= Var λ Var. Expr (Expr Expr) Key Concepts: Bound and Free Occurrences Substitution, Reduction Rules: α, β, η Confluence and Unique Normal Form
More informationCSci 450: Org. of Programming Languages Overloading and Type Classes
CSci 450: Org. of Programming Languages Overloading and Type Classes H. Conrad Cunningham 27 October 2017 (after class) Contents 9 Overloading and Type Classes 1 9.1 Chapter Introduction.........................
More informationExercise 8 Parametric polymorphism November 18, 2016
Concepts of Object-Oriented Programming AS 2016 Exercise 8 Parametric polymorphism November 18, 2016 Task 1 Consider the following Scala classes: class A class B extends A class P1[+T] class P2[T
More informationG Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing
More informationLECTURE 16. Functional Programming
LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative
More informationCS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University
CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationAbout the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming
About the Tutorial Haskell is a widely used purely functional language. Functional programming is based on mathematical functions. Besides Haskell, some of the other popular languages that follow Functional
More informationDecaf Language Reference Manual
Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationn Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades
Announcements Announcements n HW12: Transaction server n Due today at 2pm n You can use up to 2 late days, as always n Final Exam, December 17, 3-6pm, in DCC 308 and 318 n Closed book n You are allowed
More informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4303 April 9, 2010 14.00-15.30 This exam (6 pages) consists of 52 True/False
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationCSE 130, Fall 2006: Final Examination
CSE 130, Fall 2006: Final Examination Name: ID: Instructions, etc. 1. Write your answers in the space provided. 2. Wherever it says explain, write no more than three lines as explanation. The rest will
More informationPrinciples of Programming Languages 2017W, Functional Programming
Principles of Programming Languages 2017W, Functional Programming Assignment 3: Lisp Machine (16 points) Lisp is a language based on the lambda calculus with strict execution semantics and dynamic typing.
More informationn n Official Scala website n Scala API n
n Quiz 8 Announcements n Rainbow grades: HW1-8, Quiz1-6, Exam1-2 n Still grading: HW9, Quiz 7 Scala n HW10 due today n HW11 out today, due Friday Fall 18 CSCI 4430, A Milanova 1 Today s Lecture Outline
More informationLecture 7: Type Systems and Symbol Tables. CS 540 George Mason University
Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing
More informationTypes in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9)
Types in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9) Carlos Varela Rensselaer Polytechnic Institute September 23,
More informationPROGRAMMING IN HASKELL. Chapter 2 - First Steps
PROGRAMMING IN HASKELL Chapter 2 - First Steps 0 The Hugs System Hugs is an implementation of Haskell 98, and is the most widely used Haskell system; The interactive nature of Hugs makes it well suited
More informationReview. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals
Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:
More informationApplicative, traversable, foldable
Applicative, traversable, foldable Advanced functional programming - Lecture 4 Wouter Swierstra and Alejandro Serrano 1 Beyond the monad So far, we have seen how monads define a common abstraction over
More informationCollege Functors, Applicatives
College 2016-2017 Functors, Applicatives Wouter Swierstra with a bit of Jurriaan Hage Utrecht University Contents So far, we have seen monads define a common abstraction over many programming patterns.
More informationLecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]
1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,
More informationType Checking and Type Equality
Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.
More informationChapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.
Chapter 13 Object Oriented Programming Contents 13.1 Prelude: Abstract Data Types 13.2 The Object Model 13.4 Java 13.1 Prelude: Abstract Data Types Imperative programming paradigm Algorithms + Data Structures
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a
More informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False
More informationIntroduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples
Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the
More informationHaske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell
Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
More informationCompilers and computer architecture: Semantic analysis
1 / 1 Compilers and computer architecture: Semantic analysis Martin Berger Alex Jeffery October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationA First Look at ML. Chapter Five Modern Programming Languages, 2nd ed. 1
A First Look at ML Chapter Five Modern Programming Languages, 2nd ed. 1 ML Meta Language One of the more popular functional languages (which, admittedly, isn t saying much) Edinburgh, 1974, Robin Milner
More informationHaskell Overview II (2A) Young Won Lim 8/23/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationValues (a.k.a. data) representation. Advanced Compiler Construction Michel Schinz
Values (a.k.a. data) representation Advanced Compiler Construction Michel Schinz 2016 03 10 The problem Values representation A compiler must have a way of representing the values of the source language
More informationValues (a.k.a. data) representation. The problem. Values representation. The problem. Advanced Compiler Construction Michel Schinz
Values (a.k.a. data) representation The problem Advanced Compiler Construction Michel Schinz 2016 03 10 1 2 Values representation The problem A compiler must have a way of representing the values of the
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCom S 541. Programming Languages I
Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR
More informationCPS 506 Comparative Programming Languages. Programming Language Paradigm
CPS 506 Comparative Programming Languages Functional Programming Language Paradigm Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages The First Functional Programming
More informationPolymorphism and Type Inference
Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.) Compile-time
More informationOption Values, Arrays, Sequences, and Lazy Evaluation
Option Values, Arrays, Sequences, and Lazy Evaluation Björn Lisper School of Innovation, Design, and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ Option Values, Arrays,
More informationSOFTWARE ARCHITECTURE 6. LISP
1 SOFTWARE ARCHITECTURE 6. LISP Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ 2 Compiler vs Interpreter Compiler Translate programs into machine languages Compilers are
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationAn introduction introduction to functional functional programming programming using usin Haskell
An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program
More informationcis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1
topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is
More informationINF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.
INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe
More informationcs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides.
cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. We are looking for homework graders. If you are interested, send mail to cs242cs.stanford.edu
More informationObjects, Subclassing, Subtyping, and Inheritance
Objects, Subclassing, Subtyping, and Inheritance Brigitte Pientka School of Computer Science McGill University Montreal, Canada In these notes we will examine four basic concepts which play an important
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler
More informationCSE 341, Spring 2011, Final Examination 9 June Please do not turn the page until everyone is ready.
CSE 341, Spring 2011, Final Examination 9 June 2011 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationCIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL
CIS 194: Homework 3 Due Wednesday, February 11, 2015 Interpreters An interpreter is a program that takes another program as an input and evaluates it. Many modern languages such as Java 1, Javascript,
More informationCS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:
CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : In mathematics,
More informationPrinciples of Programming Languages
Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,
More informationCS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:
CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : In mathematics,
More informationTopic 7: Algebraic Data Types
Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,
More informationCompiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM
1 of 18 9/6/2010 9:40 PM Flash CS4 Professional ActionScript 3.0 Language Reference Language Reference only Compiler Errors Home All Packages All Classes Language Elements Index Appendixes Conventions
More informationAccording to Larry Wall (designer of PERL): a language by geniuses! for geniuses. Lecture 7: Haskell. Haskell 98. Haskell (cont) - Type-safe!
Lecture 7: Haskell CSC 131 Fall, 2014 Kim Bruce According to Larry Wall (designer of PERL): a language by geniuses for geniuses He s wrong at least about the latter part though you might agree when we
More informationLists. Michael P. Fourman. February 2, 2010
Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce
More information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationProgramming Languages 2nd edition Tucker and Noonan"
Programming Languages 2nd edition Tucker and Noonan" Chapter 13 Object-Oriented Programming I am surprised that ancient and Modern writers have not attributed greater importance to the laws of inheritance..."
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationPolymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy
06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationAll the operations used in the expression are over integers. a takes a pair as argument. (a pair is also a tuple, or more specifically, a 2-tuple)
Weekly exercises in INF3110 week 41 6-10.10.2008 Exercise 1 Exercise 6.1 in Mitchell's book a) fun a(x,y) = x+2*y; val a = fn : int * int -> int All the operations used in the expression are over integers.
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationAdvanced Systems Programming
Advanced Systems Programming Introduction to C++ Martin Küttler September 19, 2017 1 / 18 About this presentation This presentation is not about learning programming or every C++ feature. It is a short
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 10 Thomas Wies New York University Review Last class ML Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.8 McConnell, Steve. Code Complete, Second Edition,
More informationCSCC24 Functional Programming Typing, Scope, Exceptions ML
CSCC24 Functional Programming Typing, Scope, Exceptions ML Carolyn MacLeod 1 winter 2012 1 Based on slides by Anya Tafliovich, with many thanks to Gerald Penn and Sheila McIlraith. motivation Consider
More informationProgramming Languages Lecture 15: Recursive Types & Subtyping
CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)
More informationCSc 520 Principles of Programming Languages
CSc 520 Principles of Programming Languages 16 : Types Polymorphism Christian Collberg collberg+520@gmail.com Department of Computer Science University of Arizona Copyright c 2008 Christian Collberg [1]
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More information