COP-5555 PROGRAMMING LANGUAGEPRINCIPLES NOTES ON RPAL

Size: px
Start display at page:

Download "COP-5555 PROGRAMMING LANGUAGEPRINCIPLES NOTES ON RPAL"

Transcription

1 COP-5555 PROGRAMMING LANGUAGEPRINCIPLES NOTES ON 1. Introduction is a subset of PAL, the Pedagogic Algorithmic Language. There are three versions of PAL:, LPAL, and JPAL. The only one of terest here is. The R stands for right-reference, as opposed to L (LPAL) which stands for left-reference. The logic behd this convention comes from a tradition programmg languages, which an identifier, when occurrg on the left side of an assignment, denotes the left-value, i.e. its address, as if it occurs on the right side of the assignment, it denotes the right-value, i.e. the value stored at that address. An program is simply an expression. has no concept of assignment, nor even one of memory. There are no loops, only recursion. programs, as we shall see, consist exclusively of two notions: function defition and function application. LPAL is essentially plus assignments, memory aliasg, and other issues. JPAL, fally, islpalplus jump statements. To repeat, we will only deal with. is a functional language. Every program is nothg more than an expression, and runng an program consists of nothg more than evaluatg the expression, yieldg one result. This seems superfluous at first, but the catch is that functions are much more important than other languages. In fact, the sgle most important construct is the function. From now on, we will simply say PAL stead of. Functions PAL are so-called first-class objects. This means that unlike traditional languages such as Pascal and C, the programmer can do anythg he/she wants to with a function PAL, cludg sendg a function as a parameter to a function and returng a function from a function. We first give some examples of PAL programs: 1) let X=3 Prt(X,X**2) 2) let Abs(N) = (N ls 0 > -N N) Prt(Abs(-3)) The values prted by each of these programs are (3,9) and (3), respectively. The actual value of each program is dummy. PAL has operators (a.k.a. functors), function defitions, constant defitions, conditional expressions, function application, and recursion. The first example above illustrates a constant defition of X as 3, and function application: the function Prt is applied to the pair (X,X**2). The defition of X as 3 holds the expression Prt(X,X**2); thus the result (3,9). The second example illustrates function defitions and conditional expressions: Abs is defed as a function, that takes a parameter N and returns either -N or N, dependg on whether N is less than zero.

2 -2- PAL is a dynamically typed language. This means that unlike strongly typed languages such as Pascal or C, they type of a variable is determed at run-time, and not earlier. For example, consider the defition (not a complete PAL program) let Funny =(B >1 January ) In this defition Funny is defed as the teger 1 or the strg January, dependg on the current value of B. PAL has six major types of values: teger, truthvalue (boolean), strg, tuples, functions, and dummy. Sce the language is dynamically typed, there are several functions available to fd out what type of object is beg dealt with. These are: Isteger, Istruthvalue, Isstrg, Istuple, Isfunction, and Isdummy. All of these are functions that take an arbitrary object, and return either true or false, dependg on the type of that object. Other features of the language: Truthvalue operations Integer operations Strg operations or, &,not, eq, ne +,-,*,/,**,eq,ne,ls,gr,le,ge eq, ne, Stem S, Stern S, Conc S T 2. Defitions. Defitions PAL are of the form let <defn> <expn>. For example: let Name = Dolly Prt ( Hello,Name) Defitions can be nested arbitrarily, which case the issue of scope appears. For example: let X = 3 let Sqr X = X**2 Prt (X, Sqr X, X * Sqr X, Sqr X ** 2) The scope of X (the value 3) is the entire expression followg the first. The scope of the Sqr function is only the expression followg the second. Another form of defition is the defition, which is similar to the let defition, except that the order is reversed. For example, the above PAL program might be re-written as: (Prt (X, Sqr X, X * Sqr X, Sqr X ** 2) Sqr X = X**2) X=3 Simultaneous defitions are also allowed, usg the keyword and. For example: let X=3 and Y=5 Prt(X+Y) Note that because of this use of the keyword and, the boolean (truthvalue) conjunction operator of the same name is represented usg the symbol &.

3 -3- Fally, defitions can hold with one another, usg the with clause. Normally, the scope of a let or defition is an expression. The scope of a with defition is another defition, not an expression. For example: 3. Functions let c=3 with f x = x + c Prt(f 3) In PAL, functions are first-class objects. This means that there no silly restrictions on the circumstances which one can use a function, as there are many other languages. In PAL, functions can be given aname usg an ordary defition, passed as parameters to other functions, returned from functions, selected from other objects conditional expressions, and entered to data structures. Of course, functions can also be applied to actual values. Functions can be used arbitrarily expressions, any, say, an teger could be used. Every function has a so-called bound variable (its parameter) and a body (an expression). For example: fn X. X ls 0 > -X X Afunction can be given aname usg an ordary defition: Afunction can be passed as parameter: Afunction can be returned from a function: let Abs = fn X. X ls 0 > -X XPrt (Abs(3)) let f g = g 3 let h x = x + 1 Prt(f h) let f x = fn y.x+y Prt (f 3 2) Afunction can be selected from other objects usg the conditional: let B=true let f = (B > (fn y.y+1) (fn y.y+2) ) Prt (f 3) Afunction can be entered to a tuple (more on tuples later): N-ary functions are allowed, by usg tuples: let T=((fn x.x+1),(fn x.x+2)) Prt (T 1 3, T 2 3) let Add (x,y) = x+y Prt (Add (3,4) ) In general, a function (fn x.b) is applied to an argument A by juxtaposition, i.e. by formg the expression (fn x.b)a. There are two ways which function application can be performed: PL (programmg language) order, and normal order. 1) In PL order, the argument A is evaluated first, and then the body of the function (expression B) is evaluated, with x replaced by the value of A. 2) In normal order, Aisnot evaluated first but stead is used to replace x B LITERALLY. Then B is evaluated. These two are quite different, as we shall see later. For now, the followg example should suffice: let f x y = x Prt( f 3 (1/0) ) In normal order, fisapplied to 3 (with no attempt to evaluate the 3). The result is a function (fn y.3) (1/0), sce the 3 replaced the x. Next, the (1/0) literally replaces all the y s that occur the expression 3, i.e. none. The result is 3. In PL order, the (1/0) is evaluated first, which produces an error.

4 -4-4. Recursion. Recursion is the only way to achieve repetition PAL. Functions are not recursive by default PAL; one must dicate that a function is recursive by usg the keyword rec. The classical factorial example: let rec Fact N = Neq1 >1 N*Fact (N-1) Prt ( Fact(3) ) Ordarily (i.e. without the rec keyword) the scope of the defition of Fact would be limited to the expression on the last le. With the keyword rec, however, the scope of Fact is extended to clude the body of Fact itself, i.e. the expression N eq 1 > 1 N*Fact (N-1). Here are two examples of recursion PAL: let rec length S = Seq >0 1+length (Stern S) Prt ( length( 1,2,3 ), length ( ), length( abc ) ) let Is_perfect_Square N = Has_sqrt_ge (N,1) rec Has_sqrt_ge (N,R) = R**2 gr N > false R**2 eq N > true Has_sqrt_ge (N,R+1) Prt (Is_perfect_Square 4, Is_perfect_Square 64, Is_perfect_Square 3) It would be structive to simulate by hand the execution of each of these programs, and to actually run them on the computer. 5. Tuples The only data structure available PAL is the tuple. Tuples can be of any length (cludg zero for the nil tuple), and they can conta elements of any type, cludg other tuples. For example: let Bdate = ( June, 21, 19XX ) let Me = ( Bermudez, Manuel, Bdate, 50) Prt (Me) Tuples can be used for any purpose, sce they provide more flexibility than any other data structure. An array is a special case of a tuple, which all the components are of the same type. For example:

5 -5- let I=2 let A = (1,I,I**2,I**3,I**4,I**5) Prt (A) Atwo-dimensional array can be had by constructg a tuple of tuples: let A=(1,2) and B=(3,4) and C=(5,6) let T=(A,B,C) Prt(T) Even a triangular array can be had: let A = nil aug 1 and B=(2,3) and C=(4,5,6) let T=(A,B,C) Prt(T) To select an element from a tuple, one applies the tuple to an teger, asifthe tuple were a function. For example: let T=( a, b,true,3) Prt( T 3, T 2) Tuples can also be extended, i.e. an element (of any type) can be added to the end of an existg tuple, usg the aug (augment) operation. For example: Summarizg, here are the tuple operations: let T = (2,3) let A = T aug 4 Prt (A) E 1,E 2,...,E n Taug E Order T Null T tuple construction (tau) tuple extension (augmentation) number of elements of a tuple true if T is nil, false otherwise 6. Operator Precedence PAL Pal isalanguage rich operators. Here they are, from least to most bdg, i.e from lowest to highest precedence. let fn tau aug > or & not gr ge le ls eq ne +- */ function application Only operator remas. This is the fix operator, which allows fix use of a function. For example: let Add x y = x + y Prt 4)

6 -6-7. Examples Example 1: Here are two sample PAL programs. let Sum_list L = Partial_sum (L, Order L) rec Partial_sum (L,N) = Neq0 >0 LN+Partial_sum(L,N-1) Prt ( Sum_list (2,3,4,5) ) Example 2: let Vector_sum(A,B) = Partial_sum (A,B,Order A) rec Partial_sum (A,B,N) = Neq0 >nil (Partial_sum(A,B,N-1) aug (A N + B N) ) Prt ( Vector_sum ( (1,2,3), (4,5,6) ) ) There are many error conditions that can occur this last program. Here is a (non)-exhaustive list: Error Aisnot a tuple Bisnot a tuple Ashorter than B Bshorter than A Components not tegers Aand B components not of same type Location of error Evaluation of Order A Indexg of B N Last part of B is ignored Indexg B N Addition Addition Here an example of how toimplement one data verification: let Vector_sum(A,B) = not (Istuple A) > Error Partial_sum (A,B,Order A)... Once aga, it would be structive to hand-simulate the execution of each of these, and to run them on the computer as well.

COP4020 Programming Language Concepts Spring 2017 Sample Final Exam Questions SOLUTIONS

COP4020 Programming Language Concepts Spring 2017 Sample Final Exam Questions SOLUTIONS COP4020 Programmg Language Concepts Sprg 2017 Sample Fal Exam Questions SOLUTIONS Disclaimer: This is a collection of sample exam questions, not a sample exam. 1. Add the unary postfix auto-crement operator

More information

7.3.3 A Language With Nested Procedure Declarations

7.3.3 A Language With Nested Procedure Declarations 7.3. ACCESS TO NONLOCAL DATA ON THE STACK 443 7.3.3 A Language With Nested Procedure Declarations The C family of languages, and many other familiar languages do not support nested procedures, so we troduce

More information

Version 4, 12 October 2004 Project handed out on 12 October. Complete Java implementation due on 2 November.

Version 4, 12 October 2004 Project handed out on 12 October. Complete Java implementation due on 2 November. CS 351 Programmg Paradigms, Fall 2004 1 Project 2: gnuplot Version 4, 12 October 2004 Project handed out on 12 October. Compe Java implementation due on 2 November. 2.1 The task Implement a utility for

More information

Programming Languages

Programming Languages CSE 130 : Fall 2008 Programmg Languages Lecture 4: Variables, Environments, Scope News PA 1 due Frida 5pm PA 2 out esterda (due net Fi) Fri) Ranjit Jhala UC San Diego Variables and Bdgs Q: How to use variables

More information

Next. Tail Recursion: Factorial. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial.

Next. Tail Recursion: Factorial. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial. Next Tail Recursion: Factorial More on recursion Higher-order functions takg and returng functions Along the way, will see map and fold let rec fact n = if n

More information

Factorial. Next. Factorial. How does it execute? Tail recursion. How does it execute? More on recursion. Higher-order functions

Factorial. Next. Factorial. How does it execute? Tail recursion. How does it execute? More on recursion. Higher-order functions Next More on recursion Higher-order functions takg and returng functions Factorial let rec fact n = Along the way, will see map and fold 1 2 Factorial let rec fact n = if n

More information

About coding style Spring February 9, 2004

About coding style Spring February 9, 2004 About codg style 15-212 Sprg 2004 February 9, 2004 Contents 1 Correctness 2 2 Specification 2 3 Style 2 3.1 if-then- Expressions... 3 3.1.1 Boolean if-then- Expressions... 3 3.1.2 if-then- stead of Pattern

More information

Strong Dominating Sets of Direct Product Graph of Cayley Graphs with Arithmetic Graphs

Strong Dominating Sets of Direct Product Graph of Cayley Graphs with Arithmetic Graphs International Journal of Applied Information Systems (IJAIS) ISSN : 9-088 Volume No., June 01 www.ijais.org Strong Domatg Sets of Direct Product Graph of Cayley Graphs with Arithmetic Graphs M. Manjuri

More information

A Crash Course on Standard ML

A Crash Course on Standard ML A Crash Course on Standard ML Hongwei Xi Version of November 23, 2004 1 Start Type sml-cm at a Unix wdow to get an teractive terpreter for Standard ML (SML). You can later quit the terpreter by typg ctrl-d.

More information

Supplementary Notes on Concurrent ML

Supplementary Notes on Concurrent ML Supplementary Notes on Concurrent ML 15-312: Foundations of Programmg Languages Frank Pfenng Lecture 25 November 21, 2002 In the last lecture we discussed the π-calculus, a mimal language with synchronous

More information

Today. Recap from last Week. Factorial. Factorial. How does it execute? How does it execute? More on recursion. Higher-order functions

Today. Recap from last Week. Factorial. Factorial. How does it execute? How does it execute? More on recursion. Higher-order functions Recap from last Week Three key ways to build complex types/values 1. Each-of types Value of T contas value of T1 and a value of T2 2. One-of types Value of T contas value of T1 or a value of T2 Today More

More information

Subtyping: An introduction

Subtyping: An introduction Subtypg: An troduction Brigitte Pientka November 26, 2007 We will briefly describe the basics about subtypg. Up to now, we have shown how to enrich a language by addg new language constructs together with

More information

Preparing for Class: Watch le Videos! What is an ML program?

Preparing for Class: Watch le Videos! What is an ML program? Why are we here? CSE 341 : Programmg Languages Lecture 3 Local Bdgs, Options, Purity Zach Tatlock Sprg 2014 To work together to free our mds from the shackles of imperative programmg. 2 Preparg for Class:

More information

Computer Science 312 Fall Prelim 2 SOLUTIONS April 18, 2006

Computer Science 312 Fall Prelim 2 SOLUTIONS April 18, 2006 Computer Science 312 Fall 2006 Prelim 2 SOLUTIONS April 18, 2006 1 2 3 4 5 6 7 8 Total Grade /xx /xx /xx /xx /xx /xx /xx /xx /100 Grader 1 1. (xx pots) A. The bary representation of a natural number is

More information

1 Announcements. 2 Scan Implementation Recap. Recitation 4 Scan, Reduction, MapCollectReduce

1 Announcements. 2 Scan Implementation Recap. Recitation 4 Scan, Reduction, MapCollectReduce Recitation 4 Scan, Reduction, MapCollectReduce Parallel and Sequential Data Structures and Algorithms, 15-210 (Sprg 2013) February 6, 2013 1 Announcements How did HW 2 go? HW 3 is out get an early start!

More information

15-451/651: Design & Analysis of Algorithms November 20, 2018 Lecture #23: Closest Pairs last changed: November 13, 2018

15-451/651: Design & Analysis of Algorithms November 20, 2018 Lecture #23: Closest Pairs last changed: November 13, 2018 15-451/651: Design & Analysis of Algorithms November 20, 2018 Lecture #23: Closest Pairs last changed: November 13, 2018 1 Prelimaries We ll give two algorithms for the followg closest pair problem: Given

More information

15-451/651: Design & Analysis of Algorithms April 18, 2016 Lecture #25 Closest Pairs last changed: April 18, 2016

15-451/651: Design & Analysis of Algorithms April 18, 2016 Lecture #25 Closest Pairs last changed: April 18, 2016 15-451/651: Design & Analysis of Algorithms April 18, 2016 Lecture #25 Closest Pairs last changed: April 18, 2016 1 Prelimaries We ll give two algorithms for the followg closest pair proglem: Given n pots

More information

A Second Look At ML. Chapter Seven Modern Programming Languages, 2nd ed. 1

A Second Look At ML. Chapter Seven Modern Programming Languages, 2nd ed. 1 A Second Look At ML Chapter Seven Modern Programming Languages, 2nd ed. 1 Outline Patterns Local variable definitions A sorting example Chapter Seven Modern Programming Languages, 2nd ed. 2 Two Patterns

More information

CS 312, Fall Exam 1

CS 312, Fall Exam 1 Name: ID number: CS 312, Fall 2003 Exam 1 October 16, 2003 Problem 1 2 3 4 Total Grader Grade 18 24 28 30 There are 4 problems on this exam. Please check now that you have a complete exam booklet with

More information

Lexical Considerations

Lexical 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 information

The Phases of a Compiler. Course Overview. In Chapter 4. Syntax Analysis. Syntax Analysis. Multi Pass Compiler. PART I: overview material

The Phases of a Compiler. Course Overview. In Chapter 4. Syntax Analysis. Syntax Analysis. Multi Pass Compiler. PART I: overview material Course Overview The Phases of a Compiler PART I: overview material Introduction 2 Language processors (tombstone diagrams, bootstrappg) 3 Architecture of a compiler PART II: side a compiler 4 Sntax analsis

More information

Functions Over Lists. Programming Languages and Compilers (CS 421) Structural Recursion. Functions Over Lists. Structural Recursion : List Example

Functions Over Lists. Programming Languages and Compilers (CS 421) Structural Recursion. Functions Over Lists. Structural Recursion : List Example Functions Over Lists Programmg Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illois.edu/cs421 Based part on slides by Mattox Beckman, as updated by Vikram Adve and Gul

More information

Final Exam CSCI 1101 Computer Science I KEY. Wednesday December 16, 2015 Instructor Muller Boston College. Fall 2015

Final Exam CSCI 1101 Computer Science I KEY. Wednesday December 16, 2015 Instructor Muller Boston College. Fall 2015 Fal Exam CSCI 1101 Computer Science I KEY Wednesday December 16, 2015 Instructor Muller Boston College Fall 2015 Please do not write your name on the top of this test. Before readg further, please arrange

More information

Lexical Considerations

Lexical 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 information

Zomerlust Systems Design (CK1997/001363/23) trading as ZSD

Zomerlust Systems Design (CK1997/001363/23) trading as ZSD Zomerlust Systems Design (CK1997/001363/23) tradg as ZSD Unit D11, Clareview Busess Park 236 Lansdowne Rd fo@zsd.co.za http://www.zsd.co.za P.O. Box 46827 Glosderry, 7702 South Africa +27-21-683-1388 +27-21-674-1106

More information

1 Lexical Considerations

1 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 information

type environment updated subtype sound

type environment updated subtype sound #1 Type Checkg #2 One-Slide Summary A type environment gives types for free variables. You typecheck a let-body with an environment that has been updated to conta the new let-variable. If an object of

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

Separate Compilation. Comparison. Single Source File Programs Programs where all the code is contained within 1 file.

Separate Compilation. Comparison. Single Source File Programs Programs where all the code is contained within 1 file. Separate 1 Comparison 2 Table of Contents Sgle Source File Programs Programs where all code is contaed with 1 file. Comparison Large s results problems. Files Module Structure Security Issues Global Concerns

More information

SML A F unctional Functional Language Language Lecture 19

SML A F unctional Functional Language Language Lecture 19 SML A Functional Language Lecture 19 Introduction to SML SML is a functional programming language and acronym for Standard d Meta Language. SML has basic data objects as expressions, functions and list

More information

CS 457/557: Functional Languages

CS 457/557: Functional Languages CS 457/557: Functional Languages Lists and Algebraic Datatypes Mark P Jones Portland State University 1 Why Lists? Lists are a heavily used data structure in many functional programs Special syntax is

More information

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 NOTHING: A Language for Practice Implementation 1 Introduction NOTHING is a programming language designed

More information

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ARITHMATIC OPERATORS The assignment operator in IDL is the equals sign, =. IDL uses all the familiar arithmetic operators

More information

THAT ABOUT WRAPS IT UP Using FIX to Handle Errors Without Exceptions, and Other Programming Tricks

THAT ABOUT WRAPS IT UP Using FIX to Handle Errors Without Exceptions, and Other Programming Tricks THAT ABOUT WRAPS IT UP Usg FIX to Handle Errors Without Exceptions, and Other Programmg Tricks BRUCE J. MCADAM Technical Report ECS LFCS 97 375 Department of Computer Science University of Edburgh November

More information

Contextual Analysis (2) Limitations of CFGs (3)

Contextual Analysis (2) Limitations of CFGs (3) G53CMP: Lecture 5 Contextual Analysis: Scope I Henrik Nilsson University of Nottgham, UK This Lecture Limitations of context-free languages: Why checkg contextual constrats is different from checkg syntactical

More information

Shell CSCE 314 TAMU. Functions continued

Shell CSCE 314 TAMU. Functions continued 1 CSCE 314: Programming Languages Dr. Dylan Shell Functions continued 2 Outline Defining Functions List Comprehensions Recursion 3 A Function without Recursion Many functions can naturally be defined in

More information

COP4020 Programming Languages. Syntax Prof. Robert van Engelen

COP4020 Programming Languages. Syntax Prof. Robert van Engelen COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview Tokens and regular expressions Syntax and context-free grammars Grammar derivations More about parse trees Top-down and bottom-up

More information

A 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 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 information

Method of Semantic Web Service Discovery and Automatic Composition

Method of Semantic Web Service Discovery and Automatic Composition 298 JOURNAL OF EMERGING TECHNOLOGIES IN WEB INTELLIGENCE, VOL. 6, NO. 3, AUGUST 2014 Method of Semantic Web Service Discovery and Automatic Composition Yuem Wang Suqian College, 3 rd Department, Suqian,

More information

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions 1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Optimisation of Statistical Feature Extraction Algorithms

Optimisation of Statistical Feature Extraction Algorithms Optimisation of Statistical Feature Extraction Algorithms C. Lombard*, W.A. Smit and J.P. Maré Kentron Dynamics Mache Vision Group Keywords: statistical feature extraction, real-time implementation, optimisation.

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

LIVA. A Lite Version of Java. Shanqi Lu Jiafei Song Zihan Jiao Yanan Zhang Hyoyoon Kate Kim sl4017 js4984 zj2203 yz3054 hk2870

LIVA. A Lite Version of Java. Shanqi Lu Jiafei Song Zihan Jiao Yanan Zhang Hyoyoon Kate Kim sl4017 js4984 zj2203 yz3054 hk2870 LIVA A Lite Version of Java Shanqi Lu Jiafei Song Zihan Jiao Yanan Zhang Hyoyoon Kate Kim sl4017 js4984 zj2203 yz3054 hk2870 Table of Contents Chapter 1 Introduction... 3 Chapter 2 Language Tutorial...

More information

Fully Persistent Graphs Which One To Choose?

Fully Persistent Graphs Which One To Choose? Fully Persistent Graphs Which One To Choose? Mart Erwig FernUniversität Hagen, Praktische Informatik IV D-58084 Hagen, Germany erwig@fernuni-hagen.de Abstract. Functional programs, by nature, operate on

More information

There is usually quite a big difference

There is usually quite a big difference UNIVERSAL DATA MODELS FOR By Len Silverston There is usually quite a big difference nature various manufacturg enterprises. Each manufacturg enterprise s products may be very unique, ir manufacturg processes

More information

Typed Racket: Racket with Static Types

Typed Racket: Racket with Static Types Typed Racket: Racket with Static Types Version 5.0.2 Sam Tobin-Hochstadt November 6, 2010 Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type

More information

System Verilog Tagged Unions and Pattern Matching

System Verilog Tagged Unions and Pattern Matching System Verilog Tagged Unions and Pattern Matching (An extension to System Verilog 3.1 proposed to Accellera) Bluespec, Inc. Contact: Rishiyur S. Nikhil, CTO, Bluespec, Inc. 200 West Street, 4th Flr., Waltham,

More information

Ordered structures. Dr. C. Constantinides. Department of Computer Science and Software Engineering Concordia University Montreal, Canada

Ordered structures. Dr. C. Constantinides. Department of Computer Science and Software Engineering Concordia University Montreal, Canada Ordered structures Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada January 10, 2017 1/19 Introduction Ordered structures include tuples,

More information

COP4020 Programming Languages. Syntax Prof. Robert van Engelen

COP4020 Programming Languages. Syntax Prof. Robert van Engelen COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview n Tokens and regular expressions n Syntax and context-free grammars n Grammar derivations n More about parse trees n Top-down and

More information

Introduction to Programming in ATS

Introduction to Programming in ATS Introduction to Programmg ATS Hongwei Xi ATS Trustful Software, Inc. Copyright 2010-201? Hongwei Xi As a programmg language, ATS is both syntax-rich and feature-rich. This book troduces the reader to some

More information

Implementing Routing Policy

Implementing Routing Policy Implementg Routg Policy A routg policy structs the router to spect routes, filter them, and potentially modify their attributes as they are accepted from a peer, advertised to a peer, or redistributed

More information

On Secure Distributed Data Storage Under Repair Dynamics

On Secure Distributed Data Storage Under Repair Dynamics On Secure Distributed Data Storage Under Repair Dynamics Sameer Pawar, Salim El Rouayheb, Kannan Ramchandran University of California, Bereley Emails: {spawar,salim,annanr}@eecs.bereley.edu. Abstract We

More information

SOURCE LANGUAGE DESCRIPTION

SOURCE LANGUAGE DESCRIPTION 1. Simple Integer Language (SIL) SOURCE LANGUAGE DESCRIPTION The language specification given here is informal and gives a lot of flexibility for the designer to write the grammatical specifications to

More information

Project 2: Scheme Interpreter

Project 2: Scheme Interpreter Project 2: Scheme Interpreter CSC 4101, Fall 2017 Due: 12 November 2017 For this project, you will implement a simple Scheme interpreter in C++ or Java. Your interpreter should be able to handle the same

More information

3. Sequential Logic 1

3. Sequential Logic 1 Chapter 3: Sequential Logic 1 3. Sequential Logic 1 It's a poor sort of memory that only works backward. Lewis Carroll (1832-1898) All the Boolean and arithmetic chips that we built previous chapters were

More information

An XML Viewer for Tabular Forms for use with Mechanical Documentation

An XML Viewer for Tabular Forms for use with Mechanical Documentation An XML Viewer for Tabular Forms for use with Mechanical Documentation Osamu Inoue and Kensei Tsuchida Dept. Information & Computer Sciences Toyo University 2100, Kujirai, Kawagoe Saitama, 350-8585, Japan

More information

CSci 4223 Principles of Programming Languages

CSci 4223 Principles of Programming Languages Review CSci 4223 Prciples of Programmg Languages Lecture 8 Features learned: functions, tuples, lists, let expressions, options, records, datatypes, case expressions, type synonyms, pattern matchg, exceptions

More information

Handout 2 August 25, 2008

Handout 2 August 25, 2008 CS 502: Compiling and Programming Systems Handout 2 August 25, 2008 Project The project you will implement will be a subset of Standard ML called Mini-ML. While Mini- ML shares strong syntactic and semantic

More information

Language Reference Manual simplicity

Language Reference Manual simplicity Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna

More information

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II)

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II) Processadors de Llenguatge II Functional Paradigm Pratt A.7 Robert Harper s SML tutorial (Sec II) Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra Paradigm Shift Imperative Paradigm State Machine

More information

An example DFA: reaching definitions

An example DFA: reaching definitions Dataflow analysis: what is it? Dataflow analysis A common framework for expressg algorithms that compute formation ab a program Why is such a framework useful? Dataflow analysis: what is it? A common framework

More information

A general introduction to Functional Programming using Haskell

A general introduction to Functional Programming using Haskell A general introduction to Functional Programming using Haskell Matteo Rossi Dipartimento di Elettronica e Informazione Politecnico di Milano rossi@elet.polimi.it 1 Functional programming in a nutshell

More information

L-System Fractal Generator: Language Reference Manual

L-System Fractal Generator: Language Reference Manual L-System Fractal Generator: Language Reference Manual Michael Eng, Jervis Muindi, Timothy Sun Contents 1 Program Definition 3 2 Lexical Conventions 3 2.1 Comments...............................................

More information

Copyright 2017 Ingenico epayments. PrestaShop Extension

Copyright 2017 Ingenico epayments. PrestaShop Extension PrestaShop Extension Table of contents 1. Disclaimer 2. Installation PrestaShop 2.1 Requirements 2.2 Installation Process 3. Configuration 3.1 Ingenico epayments back office 3.1.1 Admistrative details

More information

CLIP - A Crytographic Language with Irritating Parentheses

CLIP - A Crytographic Language with Irritating Parentheses CLIP - A Crytographic Language with Irritating Parentheses Author: Duan Wei wd2114@columbia.edu Yi-Hsiu Chen yc2796@columbia.edu Instructor: Prof. Stephen A. Edwards July 24, 2013 Contents 1 Introduction

More information

EZ- ASCII: Language Reference Manual

EZ- ASCII: Language Reference Manual EZ- ASCII: Language Reference Manual Dmitriy Gromov (dg2720), Feifei Zhong (fz2185), Yilei Wang (yw2493), Xin Ye (xy2190), Joe Lee (jyl2157) Table of Contents 1 Program Definition... 3 2 Lexical Conventions...

More information

Programming Language Concepts, cs2104 Lecture 04 ( )

Programming Language Concepts, cs2104 Lecture 04 ( ) Programming Language Concepts, cs2104 Lecture 04 (2003-08-29) Seif Haridi Department of Computer Science, NUS haridi@comp.nus.edu.sg 2003-09-05 S. Haridi, CS2104, L04 (slides: C. Schulte, S. Haridi) 1

More information

Overloading, Type Classes, and Algebraic Datatypes

Overloading, Type Classes, and Algebraic Datatypes Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827

More information

Formal Reasoning about Communication Systems II

Formal Reasoning about Communication Systems II Formal Reasong about Communication Systems II Automated Fast-Track Reconfiguration Christoph Kreitz Abstract. We present formal techniques for improvg the performance of group communication systems built

More information

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, "hi", 3.2), c 4, a 1, b 5} 9/10/2017 4

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, hi, 3.2), c 4, a 1, b 5} 9/10/2017 4 Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a # true;; - : bool = true # false;; - : bool

More information

CMSC 330: Organization of Programming Languages. Functional Programming with Lists

CMSC 330: Organization of Programming Languages. Functional Programming with Lists CMSC 330: Organization of Programming Languages Functional Programming with Lists 1 Lists in OCaml The basic data structure in OCaml Lists can be of arbitrary length Implemented as a linked data structure

More information

Tiger Compiler Reference Manual

Tiger Compiler Reference Manual Tiger Compiler Reference Manual Edition October 23, 2012 Akim Demaille and Roland Levilla This document presents the EPITA version of the Tiger language and compiler. This revision, $Id: 1637447e141ac9754dfe02bc8f39fa9cecfee327

More information

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives CS 6A Scheme Fall 208 Discussion 8: October 24, 208 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

More information

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Winter 2003 February 10, 2003 1 Introduction This document is a quick reference guide to common features of the Scheme language. It is by no means intended to be a complete

More information

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions PROGRAMMING IN HASKELL CS-205 - Chapter 6 - Recursive Functions 0 Introduction As we have seen, many functions can naturally be defined in terms of other functions. factorial :: Int Int factorial n product

More information

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited

More information

Imperative languages

Imperative languages Imperative languages Von Neumann model: store with addressable locations machine code: effect achieved by changing contents of store locations instructions executed in sequence, flow of control altered

More information

Chapter 3 Linear Structures: Lists

Chapter 3 Linear Structures: Lists Plan Chapter 3 Linear Structures: Lists 1. Lists... 3.2 2. Basic operations... 3.4 3. Constructors and pattern matching... 3.5 4. Polymorphism... 3.8 5. Simple operations on lists... 3.11 6. Application:

More information

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT 1 Satisfiability (SAT) Problem 2 Boolean Expressions Boolean,

More information

Transformations on the Complex Γ Plane

Transformations on the Complex Γ Plane 2/12/27 Transformations on the Complex 1/7 Transformations on the Complex Γ Plane The usefulness of the complex Γ plane is apparent when we consider aga the termated, lossless transmission le: z = z =

More information

The Typed Racket Guide

The Typed Racket Guide The Typed Racket Guide Version 5.3.6 Sam Tobin-Hochstadt and Vincent St-Amour August 9, 2013 Typed Racket is a family of languages, each of which enforce

More information

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015 SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

Writing an Interpreter Thoughts on Assignment 6

Writing an Interpreter Thoughts on Assignment 6 Writing an Interpreter Thoughts on Assignment 6 CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, March 27, 2017 Glenn G. Chappell Department of Computer Science

More information

Lists. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca

Lists. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca Lists Adrian Groza Department of Computer Science Technical University of Cluj-Napoca Recall... Parameter evaluation Call-by-value Call-by-name Call-by-need Functions Infix operators Local declarations,

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

Chapter 3 Linear Structures: Lists

Chapter 3 Linear Structures: Lists Plan Chapter 3 Linear Structures: Lists 1. Two constructors for lists... 3.2 2. Lists... 3.3 3. Basic operations... 3.5 4. Constructors and pattern matching... 3.6 5. Simple operations on lists... 3.9

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries

More information

SOFTWARE ENGINEERING DESIGN I

SOFTWARE ENGINEERING DESIGN I 2 SOFTWARE ENGINEERING DESIGN I 3. Schemas and Theories The aim of this course is to learn how to write formal specifications of computer systems, using classical logic. The key descriptional technique

More information

An Introduction to Scheme

An Introduction to Scheme An Introduction to Scheme Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Stéphane Ducasse 1 Scheme Minimal Statically scoped Functional Imperative Stack manipulation Specification

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Implementation of a Sudoku Solver Using Reduction to SAT

Implementation of a Sudoku Solver Using Reduction to SAT Implementation of a Sudoku Solver Using Reduction to SAT For this project you will develop a Sudoku solver that receives an input puzzle and computes a solution, if one exists. Your solver will: read an

More information

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives CS 61A Scheme Spring 2018 Discussion 7: March 21, 2018 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme

More information

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA DECISION STRUCTURES: USING IF STATEMENTS IN JAVA S o far all the programs we have created run straight through from start to finish, without making any decisions along the way. Many times, however, you

More information

Conditional Control Structures. Dr.T.Logeswari

Conditional Control Structures. Dr.T.Logeswari Conditional Control Structures Dr.T.Logeswari TEST COMMAND test expression Or [ expression ] Syntax Ex: a=5; b=10 test $a eq $b ; echo $? [ $a eq $b] ; echo $? 2 Unix Shell Programming - Forouzan 2 TEST

More information

Implementing Routing Policy

Implementing Routing Policy A routg policy structs the router to spect routes, filter them, and potentially modify their attributes as they are accepted from a peer, advertised to a peer, or redistributed from one routg protocol

More information

Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives

Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives CS 6A Scheme Fall 207 Discussion 7: October 25, 207 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

More information