1 Topics Covers everything –1) in slides –2) from the very beginning. Language classification, history, and comparison Programming paradigms –Structured.

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

CSE 3341/655; Part 4 55 A functional program: Collection of functions A function just computes and returns a value No side-effects In fact: No program.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
CSE 341, Winter Type Systems Terms to learn about types: –Type –Type system –Statically typed language –Dynamically typed language –Type error –Strongly.
1 prolog :-in(2014).. 2 Prolog Based on first-order predicate calculus – Allow Horn clauses (a subset of predicate calculus) only – Execution of a Prolog.
Language Paradigms Programming languages. Language paradigms. World view of imperative languages. World view of functional languages. World view.
C. Varela1 Logic Programming (PLP 11.3) Prolog Imperative Control Flow: Backtracking Cut, Fail, Not Carlos Varela Rennselaer Polytechnic Institute September.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Presented by Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion.
Type Inference: CIS Seminar, 11/3/2009 Type inference: Inside the Type Checker. A presentation by: Daniel Tuck.
CS 331, Principles of Programming Languages Introduction.
1 (Functional (Programming (in (Scheme)))) Jianguo Lu.
1 440 Review Topics Covers everything – in slides – from the very beginning. Language classification, history, and comparison How to describe.
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
Comp. Eng. SW Lab II: FP with Scheme 1 Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office.
High-Level Programming Languages: C++
Programming languages1 Programming paradigms Families of programming languages.
1 440 Midterm 2012 fall. Given the following two classes: public class A { void doSomething () { System.out.println("A"); } public class B extends A{
Programming Paradigms Procedural Functional Logic Object-Oriented.
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
CSC3315 (Spring 2009)1 CSC 3315 Programming Paradigms Scheme Language Hamid Harroud School of Science and Engineering, Akhawayn University
331 Final Spring Details 6-8 pm next Monday Comprehensive with more emphasis on material since the midterm Study example finals and midterm exams.
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 7.
CS 152: Programming Language Paradigms February 17 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
1 prolog :-in(2009).. 2 Prolog Based on first-order predicate calculus –Allow Horn clauses (a subset of predicate calculus) only –Execution of a Prolog.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 8.
CS 330 Programming Languages 11 / 13 / 2008 Instructor: Michael Eckmann.
COP4020 Programming Languages Functional Programming Prof. Xin Yuan.
CS 152: Programming Language Paradigms February 26 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
On Using Scheme to Introduce Prolog Daniel E. Stevenson and Michael R. Wick Department of Computer Science University of Wisconsin - Eau Claire Eau Claire,
331 Final Fall Details 3:30-5:30 Friday December 17 th LH4 Comprehensive with more emphasis on material since the midterm Study example finals and.
CS 331, Principles of Programming Languages Chapter 1.
Logical and Functional Programming
CSE 341, S. Tanimoto Wrapup - 1 Wrapup Programming Languages as systems for specifying computation Comparing Lisp, Java and Perl The future.
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Programming Languages
CS 152: Programming Language Paradigms March 12 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
C H A P T E R T H R E E Type Systems and Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office Functional Programming.
A Short History of PL's (MacLennan 1999) “Zeroth Generation” (1940's-50's): machine language / assembly: if/then, read/write, store, goto
C. Varela1 Logic Programming (PLP 11, CTM 9.3) Prolog Imperative Control Flow: Backtracking, Cut, Fail, Not Lists, Append Carlos Varela Rennselaer Polytechnic.
Copyright © 2009 Elsevier Chapter 11 :: Logic Languages And other online sources (see links on schedule page) Michael L. Scott Based on Programming Language.
Review for Test 2 Chapters 5 (start at 5.4), 6.1, , 12, 13, 15.1, Python.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Functional Programming
Functional Programming Languages
CS 326 Programming Languages, Concepts and Implementation
Representation, Syntax, Paradigms, Types
CS 326 Programming Languages, Concepts and Implementation
Scheme : variant of LISP
Carlos Varela Rensselaer Polytechnic Institute November 17, 2017
Syntax-based Testing CS 4501 / 6501 Software Testing
Nondeterministic Evaluation
Midterm Review In Text: Chapters 1-3, 5-7, 15, 16.
FP Foundations, Scheme In Text: Chapter 14.
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
Chapter 12 :: Logic Languages
Representation, Syntax, Paradigms, Types
Type Systems Terms to learn about types: Related concepts: Type
Carlos Varela Rennselaer Polytechnic Institute November 15, 2016
OUTPUT DESIGN PRINT K, expression list K FORMAT (specification list)
Presentation transcript:

1 Topics Covers everything –1) in slides –2) from the very beginning. Language classification, history, and comparison Programming paradigms –Structured programming vs. Unstructured programming –Imperative programming vs. Declarative programming –Functional programming (Scheme, lambda calculus, XSLT, Mapreduce) –Logic programming (Prolog, Horn Clause) –Object-oriented programming (polymorphism) Concepts and programming

2 Types of questions Multiple choices; true/false; filling in blanks. Running results of programs; Modify programs; Short explanations; Others.

3 BNF was first used to describe the syntax of which language: A. C B. Fortran C. Algol D. COBOL E. LISP F. None of the above

4 Which of the following language is not a declarative language? A. Java B. Prolog C. SQL D. Scheme E. None of the above.

5 Which of the following is the closest to the theoretical foundation of Prolog language? –BNF; –Horn clause; –Lambda calculus; –First order logic; –None of the above.

6 Which one of the following is not a type of polymorphism –coercion –overloading –overriding –generics – All of them are types of polymorphism

7 Given the expression (( x. x) x.x)a in lambda calculus. Derive the expression as far as possible using β- reduction. The final result will be: –( x.x)a – x.x –xa –a –none of the above

8 Given the expression (( x.x)( x.xxx))a in lambda calculus. Derive the expression as far as possible using β-reduction. The final result will be: –xx – x.x –Xa –a –aa –aaa –none above

9 ( x y. x y) ( x. x y) ( a b. a b)  ( x z. x z) ( x. x y) ( a b. a b)  conversion  ( z. ( x. x y) z) ( a b. a b)  reduction  ( x. x y) ( a b. a b)  reduction  ( a b. a b) y  reduction  ( b. y b)  reduction  y  reduction

10 What is the value of (map (lambda (x) (* 2 x)) (1 2 3)) ? –a run-time error – ( ) (the empty list) –(3 4 5) –(2 4 6) –12 –none of the above What is the value of (map (lambda (x) (* 2 x)) '(1 2 3)) ? What is the value of (eval (map (lambda (x) (* 2 x)) '(1 2 3)))?

11 Given a Prolog rule A:-B,C. It is equivalent to

12 General form of a rule (Horn Clause) A :- B1, B2,...., Bn. meaning A is true if B1 and B2 and... Bn are all true Clause: a disjunction of literals Horn clause: if it contains at most one positive literal.

13 True or False? –XPath is a language that is not in XML format. –Both Scheme and Prolog are declarative languages. –The expressive power of Prolog is stronger than first order logic. –In Prolog, changing the order of subgoals will not lead to different results.

14 edge(a,b). edge(b,c). edge(c,d). edge(d,e). edge(b,e). edge(d,f). path(X,Y):-edge(X,Z), path(Z,Y). path(X,X).

15 Write the result of running the following Scheme programs. (define (f lst) (if (null? lst) lst (append (f (cdr lst)) (list (car lst))))) (f '(1 2 3)) % reverse? (define (g lst n); assumes lst is non-empty and n >= 0 (if (= n 0) (car lst) (g (cdr lst) (- n 1)))) (g '( ) 2) %n-th element

16 rainy(seattle). rainy(rochester). cold(rochester). snowy(X):-rainy(X), cold(X). p([ ],[ ]). p([H|T],L) :- p(T,Z), append(Z,[H],L). likes(john, mary). likes(dwight, X). likes(john, X):-likes(mary, X). likes(mary, sue). Write the answer(s) of the following queries. If there are more than one answer, write all of them. | ?- snowy(X). | ?- p([1, 2, 3], X). | ?- likes(X, mary).

17 (define f (lambda (x) (lambda (y) (+ x y)))) (define (g x) ((f x) 3)) (define h (lambda (x) (lambda (y) (y x)))) (define (p f) ((h 2) f)) a). What is the return value of (g 2)? 5 b). What is the return value of (p +)? 2

18 Assuming that the following definitions are executed in this order: (define b ‘( )) (define c (cons (car (cdr b)) (list ‘a ‘b ‘c))) What is the result of typing the following into the Scheme interpreter: c –(14 a b c) (car (cdr (cdr c))) –b–b

19 Given the following XML document as an input for XSLT programs, answer the following questions: Joe Smith Andrew Wang Steve Miller Write the output of the following XSLT program. You don’t need to write the exact spaces and carriage returns. first name is