Compound Data in Java. Instances of Compound Data Types. Armadillos. Design: Functional to Object-Oriented. Beginner Scheme:
|
|
|
- Flora Casey
- 9 years ago
- Views:
Transcription
1 Compound Data in Java Design: Functional to Object-Oriented Semantics of Local Definitions Beginner Scheme: ; A snake is ; (make-snake sym num sym) (define-struct snake (name weight food)) Beginner Java: class Snake { String name; String food; Snake(String name, double weight, String food) { this.name = name; this.weight = weight; this.food = food; Beginner Scheme: Beginner Java: Instances of Compound Data Types (make-snake Slinky 12 rats) (make-snake Slimey 5 grass) new Snake("Slinky", 12, "rats") new Snake("Slimey", 5, "grass") Armadillos class Dillo { boolean alive; Dillo(double weight, boolean alive) { this.weight = weight; this.alive = alive; new Dillo(2, true) new Dillo(3, false) 1-4
2 Posns class Posn { int x; int y; Posn(int x, int y) { this.x = x; this.y = y; new Posn(0, 0) new Posn(1, -2) Ants class Ant { Posn loc; Ant(double weight, Posn loc) { this.weight = weight; this.loc = loc; new Ant(0.0001, new Posn(0, 0)) new Ant(0.0002, new Posn(1, -2)) Beginner Scheme: Data with Variants ; An animal is either ; - snake ; - dillo ; - ant class Snake extends Animal { as before class Dillo extends Animal { as before class Ant extends Animal { as before Variants in Java A data definition with variants must refer only to other data definitions (which are not built in) ; A grade is either ; - false ; - num ; A grade is either ; - no-grade ; - num-grade ; A no-grade is ; (make-no-grade) (define-struct no-grade ()) ; A num-grade is ; (make-num-grade num) (define-struct num-grade (n)) A data definition can be a variant in at most one other data definition 5-11
3 From Scheme to Java So far, we ve translated data definitions: ; A snake is ; (make-snake sym num sym) (define-struct snake (name weight food)) class Snake { String name; String food; Snake(String name, double weight, String food) { this.name = name; this.weight = weight; this.food = food; Functions in Scheme ; A snake is ; (make-snake sym num sym) (define-struct snake (name weight food)) ; snake-lighter? : snake num -> bool ; Determines whether s is < n lbs (define (snake-lighter? s n) (< (snake-weight s) n)) (snake-lighter? (make-snake Slinky 10 rats) 10) "should be" false (snake-lighter? (make-snake Slimey 5 grass) 10) "should be" false Functions in Java class Snake { String name; String food; Snake(String name, double weight, String food) { this.name = name; this.weight = weight; this.food = food; // Determines whether it s < n lbs boolean islighter(double n) { return this.weight < n; new Snake("Slinky", 10, "rats").islighter(10) "should be" false Functions in Java class Snake { String name; String food; Snake(String name, double weight, String food) { this.name = name; A method in this.weight = weight; Snake has an this.food = food; implicit Snake this argument // Determines whether it s < n lbs boolean islighter(double n) { return this.weight < n; new Snake("Slinky", 10, "rats").islighter(10) "should be" false 12-15
4 Method Calls in Java Templates Original tests: Scheme: (snake-lighter? (make-snake Slinky 10 rats) 10) "should be" false In Scheme: ; A snake is ; (make-snake sym num sym) (define-struct snake (name weight food)) Java: new Snake("Slinky", 10, "rats").islighter(10) "should be" false ; func-for-snake : snake -> (define (func-for-snake s) (snake-name s) (snake-weight s) (snake-food s) ) Templates Functions with Variants Same idea works for Java: class Snake { String name; String food; Snake(String name, double weight, String food) { this.name = name; this.weight = weight; this.food = food; methodforsnake() { this.name this.weight this.food ; An animal is either ; - snake ; - dillo ; - ant ; animal-is-lighter? : animal num -> bool (define (animal-is-lighter? a n) [(snake? a) (snake-is-lighter? s n)] [(dillo? a) (dillo-is-ligheter? s n)] [(ant? a) (ant-is-lighter? s n)])) ; snake-is-lighter? : snake num -> bool (define (snake-is-lighter? s n) ) ; dillo-is-lighter? : dillo num -> bool (define (dillo-is-lighter? d n) ) ; ant-is-lighter? : ant num -> bool (define (ant-is-lighter? a n) ) 16-19
5 Methods with Variants Translating Functions to Methods abstract boolean islighter(double n); class Snake extends Animal { boolean islighter(double n) { class Dillo extends Animal { boolean islighter(double n) { class Ant extends Animal { boolean islighter(double n) { ; An animal is either ; - snake ; - dillo ; - ant ; animal-is-lighter? : animal num -> bool (define (animal-is-lighter? a n) [(snake? a) (snake-is-lighter? s n)] [(dillo? a) (dillo-is-ligheter? s n)] [(ant? a) (ant-is-lighter? s n)])) ; snake-is-lighter? : snake num -> bool (define (snake-is-lighter? s n) ) ; dillo-is-lighter? : dillo num -> bool (define (dillo-is-lighter? d n) ) ; ant-is-lighter? : ant num -> bool (define (ant-is-lighter? a n) ) abstract boolean islighter(double n); class Snake extends Animal { boolean islighter(double n) { class Dillo extends Animal { boolean islighter(double n) { class Ant extends Animal { boolean islighter(double n) { Translating Functions to Methods Translating Functions to Methods ; An animal is either ; - snake ; - dillo ; - ant ; animal-is-lighter? : animal num -> bool (define (animal-is-lighter? a n) [(snake? a) (snake-is-lighter? s n)] [(dillo? a) (dillo-is-ligheter? s n)] [(ant? a) (ant-is-lighter? s n)])) Data definition turns into class declarations ; An animal is either ; - snake ; - dillo ; - ant ; animal-is-lighter? : animal num -> bool (define (animal-is-lighter? a n) [(snake? a) (snake-is-lighter? s n)] [(dillo? a) (dillo-is-ligheter? s n)] [(ant? a) (ant-is-lighter? s n)])) Variant functions turn into variant methods all with the same contract after the implicit argument ; snake-is-lighter? : snake num -> bool (define (snake-is-lighter? s n) ) ; dillo-is-lighter? : dillo num -> bool (define (dillo-is-lighter? d n) ) ; ant-is-lighter? : ant num -> bool (define (ant-is-lighter? a n) ) abstract boolean islighter(double n); class Snake extends Animal { boolean islighter(double n) { ; snake-is-lighter? : snake num -> bool (define (snake-is-lighter? s n) ) ; dillo-is-lighter? : dillo num -> bool (define (dillo-is-lighter? d n) ) ; ant-is-lighter? : ant num -> bool (define (ant-is-lighter? a n) ) abstract boolean islighter(double n); class Snake extends Animal { boolean islighter(double n) { class Dillo extends Animal { boolean islighter(double n) { class Dillo extends Animal { boolean islighter(double n) { class Ant extends Animal { boolean islighter(double n) { class Ant extends Animal { boolean islighter(double n) { 20-23
6 Translating Functions to Methods Lists of Things ; An animal is either ; - snake ; - dillo ; - ant ; animal-is-lighter? : animal num -> bool (define (animal-is-lighter? a n) [(snake? a) (snake-is-lighter? s n)] [(dillo? a) (dillo-is-ligheter? s n)] [(ant? a) (ant-is-lighter? s n)])) ; snake-is-lighter? : snake num -> bool (define (snake-is-lighter? s n) ) ; dillo-is-lighter? : dillo num -> bool (define (dillo-is-lighter? d n) ) ; ant-is-lighter? : ant num -> bool (define (ant-is-lighter? a n) ) Function with variant-based cond turns into just an abstract method declaration abstract boolean islighter(double n); class Snake extends Animal { boolean islighter(double n) { class Dillo extends Animal { boolean islighter(double n) { class Ant extends Animal { boolean islighter(double n) { abstract class ListOfThing { abstract int length(); class EmptyListOfThing extends ListOfThing { EmptyListOfThing() { int length() { return 0; class ConsListOfThing extends ListOfThing { Thing first; ListOfThing rest; ConsListOfThing(Thing first, ListOfThing rest) { this.first = first; this.rest = rest; int length() { return 1 + this.rest.length(); Trees of Things Implementing Methods Directly abstract class TreeOfThing { abstract int count(); class EmptyTreeOfThing extends TreeOfThing { EmptyTreeOfThing() { int count() { return 0; class ConsTreeOfThing extends TreeOfThing { Thing v; TreeOfThing left; TreeOfThing right; ConsTreeOfThing(Thing v, TreeOfThing left, TreeOfThing right) { this.v = v; this.left = left; this.right = right; int count() { return 1 + this.left.count() + this.right.count(); Some Scheme methods on animal can be implemented with other animal functions: ; animal-light? : animal -> bool ; Determines whether a is less than 10 lbs (define (animal-light? a) (animal-lighter? a 10)) In Java, this corresponds to a non-abstract method in an abstract class: boolean islight() { return this.islighter(10); 24-28
7 Random Numbers Design: Functional to Object-Oriented Semantics of Local Definitions The random operator returns a different result for different calls with the same input: > (random 3) 0 > (random 3) 2 > (random 3) 1 > (random 3) 2 Random Symbols Suppose we need a random-symbol function > > huey > > louie Random Symbols ; random-symbol : sym sym sym -> sym (define (random-symbol a b c) [(= (random 3) 0) a] [(= (random 3) 1) b] [(= (random 3) 2) c])) This doesn t work, because random produces a different result each time Can we implement it with random? 29-33
8 Saving a Random Number A Random Constant On the other hand (define n (random 3)) (list n n n) produces (list 0 0 0), (list 1 1 1), or (list 2 2 2) Constant definitions name constants, so (random 3) must be evaluted when defining n Try it in the stepper Does this work? (define n (random 3)) ; random-symbol : sym sym sym -> sym (define (random-symbol a b c) [(= n 0) a] [(= n 1) b] [(= n 2) c])) Not quite, because it always picks the same symbol We want (define n (random 3)) that is local to random-symbol s body Local Definitions This works, in the Intermediate language ; random-symbol : sym sym sym -> sym (define (random-symbol a b c) [(= n 0) a] [(= n 1) b] [(= n 2) c]))) The local form has definitions and a body Local definitions are only visible in the body Local definitions are evaluated only when the local is evaluated The result of local is the result of its body (define (random-symbol a b c) [(= n 0) a] [(= n 1) b] [(= n 2) c]))) [(= n 0) huey] [(= n 1) ] [(= n 2) louie])) 34-42
9 [(= n 0) huey] [(= n 1) ] [(= n 2) louie])) (define n17 (random 3)) [(= n17 0) huey] (define n17 (random 3)) [(= n17 0) huey] [(= n17 0) huey] Evaluation of local lifts and renames the definition [(= n17 0) huey] [(= 1 0) huey] [(= 1 0) huey] [false huey] Evaluation of a constant name finds the value 43-50
10 [false huey] [(= 1 1) ] [(= 1 1) ] [true ] [true ] 51-58
11 [(= n 0) huey] [(= n 1) ] [(= n 2) louie])) [(= n 0) huey] [(= n 1) ] [(= n 2) louie])) (define n45 (random 3)) [(= n45 0) huey] [(= n45 1) ] [(= n45 2) louie]) Evaluation of local picks a new name each time (define n45 (random 3)) [(= n45 0) huey] [(= n45 1) ] [(= n45 2) louie]) (define n45 0) [(= n45 0) huey] [(= n45 1) ] [(= n45 2) louie]) Another Example ; kind-of-blue? : image -> bool (define (kind-of-blue? i) (and (> (total-blue (image->color-list i)) (total-red (image->color-list i))) (> (total-blue (image->color-list i)) (total-green (image->color-list i))))) Easier to read, converts image only once: (define (kind-of-blue? i) (local [(define colors (image->color-list i))] (and (> (total-blue colors) (total-red colors)) (> (total-blue colors) (total-green colors))))) 59-65
12 Better: Another Example (define (eat-apples l) [(empty? l) empty] [(cons? l) [(symbol=? (first l) apple) (eat-apples (rest l))] [else (cons (first l) (eat-apples (rest l)))])])) (define (eat-apples l) [(empty? l) empty] [(cons? l) (local [(define ate-rest (eat-apples (rest l)))] [(symbol=? (first l) apple) ate-rest] [else (cons (first l) ate-rest)]))])) Another Use for Local local can define functions as well as constants This is useful for making a function private (define (random-symbol a b c) (local [(define (real-random-symbol a b c) [(= n 0) a] [(= n 1) b] [(= n 2) c])))] [(and (symbol? a) (symbol? b) (symbol? c)) (real-random-symbol a b c)] [else (error random-symbol "not a symbol")]))) Use Check Syntax and mouse over variables Lexical Scope (define (random-symbol a b c) (local [(define (real-random-symbol a b c) [(= n 0) a] [(= n 1) b] [(= n 2) c])))] [(and (symbol? a) (symbol? b) (symbol? c)) (real-random-symbol a b c)] [else (error random-symbol "not a symbol")]))) Italic a could be changed to z without affecting non-italic a, no matter how the code runs In other words, bindings are static; this is lexical scope 66-70
Lecture 9. Semantic Analysis Scoping and Symbol Table
Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax
Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
Writing Functions in Scheme. Writing Functions in Scheme. Checking My Answer: Empty List. Checking My Answer: Empty List
Writing Functions in Scheme Writing Functions in Scheme Suppose we want a function ct which takes a list of symbols and returns the number of symbols in the list (ct (a b c)) 3 (ct ()) 0 (ct (x y z w t))
Introduction to formal semantics -
Introduction to formal semantics - Introduction to formal semantics 1 / 25 structure Motivation - Philosophy paradox antinomy division in object und Meta language Semiotics syntax semantics Pragmatics
Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language
Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Chapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
Lab Experience 17. Programming Language Translation
Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly
Semester Review. CSC 301, Fall 2015
Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!
Stack vs. Heap. Introduction to Programming. How the Stack Works. Primitive vs. Reference Types. Stack
Primitive vs. Reference Types Introduction to Programming with Java, for Beginners Primitive vs. References Type Stack vs. Heap Null Pointer Exception Keyword this Strings Has a Relationship We ve seen
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
1 Introduction. 2 An Interpreter. 2.1 Handling Source Code
1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons
How To Program In Scheme (Prolog)
The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction Next up: Numeric operators, REPL, quotes, functions, conditionals Types and values
Code Kingdoms Learning a Language
codekingdoms Code Kingdoms Unit 2 Learning a Language for kids, with kids, by kids. Resources overview We have produced a number of resources designed to help people use Code Kingdoms. There are introductory
Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
Semantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
Basic Object-Oriented Programming in Java
core programming Basic Object-Oriented Programming in Java 1 2001-2003 Marty Hall, Larry Brown http:// Agenda Similarities and differences between Java and C++ Object-oriented nomenclature and conventions
Compiler Construction
Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation
PL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
Programming Languages
Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately
03 - Lexical Analysis
03 - Lexical Analysis First, let s see a simplified overview of the compilation process: source code file (sequence of char) Step 2: parsing (syntax analysis) arse Tree Step 1: scanning (lexical analysis)
Data Structures and Algorithms
Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list
DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan
DATA 301 Introduction to Data Analytics Microsoft Excel VBA Dr. Ramon Lawrence University of British Columbia Okanagan [email protected] DATA 301: Data Analytics (2) Why Microsoft Excel Visual Basic
Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!
Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)
Abstract Class & Java Interface
Abstract Class & Java Interface 1 Agenda What is an Abstract method and an Abstract class? What is Interface? Why Interface? Interface as a Type Interface vs. Class Defining an Interface Implementing an
Dart a modern web language
Dart a modern web language or why web programmers need more structure Kasper Lund & Lars Bak Software engineers, Google Inc. Object-oriented language experience: 26 + 12 years The Web Is Fantastic The
Contents. 9-1 Copyright (c) 1999-2004 N. Afshartous
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
Selection Statements
Chapter 5 Selection Statements 1 Statements So far, we ve used return statements and expression ess statements. e ts. Most of C s remaining statements fall into three categories: Selection statements:
Computer Programming I
Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,
Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game
Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Directions: In mobile Applications the Control Model View model works to divide the work within an application.
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005
University of Toronto Department of Electrical and Computer Engineering Midterm Examination CSC467 Compilers and Interpreters Fall Semester, 2005 Time and date: TBA Location: TBA Print your name and ID
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 7 Scanner Parser Project Wednesday, September 7 DUE: Wednesday, September 21 This
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
Programming Languages Featherweight Java David Walker
Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized
Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition
Java 6 'th edition Concepts INTERNATIONAL STUDENT VERSION CONTENTS PREFACE vii SPECIAL FEATURES xxviii chapter i INTRODUCTION 1 1.1 What Is Programming? 2 J.2 The Anatomy of a Computer 3 1.3 Translating
The C++ Language. Loops. ! Recall that a loop is another of the four basic programming language structures
The C++ Language Loops Loops! Recall that a loop is another of the four basic programming language structures Repeat statements until some condition is false. Condition False True Statement1 2 1 Loops
Visual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
Stack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
Symbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
Programming Project 1: Lexical Analyzer (Scanner)
CS 331 Compilers Fall 2015 Programming Project 1: Lexical Analyzer (Scanner) Prof. Szajda Due Tuesday, September 15, 11:59:59 pm 1 Overview of the Programming Project Programming projects I IV will direct
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
The Clean programming language. Group 25, Jingui Li, Daren Tuzi
The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
Government Girls Polytechnic, Bilaspur
Government Girls Polytechnic, Bilaspur Name of the Lab: Internet & Web Technology Lab Title of the Practical : Dynamic Web Page Design Lab Class: CSE 6 th Semester Teachers Assessment:20 End Semester Examination:50
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
Sample CSE8A midterm Multiple Choice (circle one)
Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names
Functional Programming. Functional Programming Languages. Chapter 14. Introduction
Functional Programming Languages Chapter 14 Introduction Functional programming paradigm History Features and concepts Examples: Lisp ML 1 2 Functional Programming Functional Programming Languages The
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.
Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state
High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16
Advanced compiler construction Michel Schinz 2007 03 16 General course information Teacher & assistant Course goals Teacher: Michel Schinz [email protected] Assistant: Iulian Dragos INR 321, 368 64
Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
arrays C Programming Language - Arrays
arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)
csce4313 Programming Languages Scanner (pass/fail)
csce4313 Programming Languages Scanner (pass/fail) John C. Lusth Revision Date: January 18, 2005 This is your first pass/fail assignment. You may develop your code using any procedural language, but you
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Statements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
IRA EXAMPLES. This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account).
IRA EXAMPLES This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account). Definite Counting Loop Example IRA After x Years This first example illustrates
Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions
COMP209 Object Oriented Programming Designing Classes 2 Mark Hall Programming by Contract (adapted from slides by Mark Utting) Preconditions Postconditions Class invariants Programming by Contract An agreement
CmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #12 John Ridgway March 10, 2015 1 Implementations of Queues 1.1 Linked Queues A Linked Queue Implementing a queue with a linked list is
The Cool Reference Manual
The Cool Reference Manual Contents 1 Introduction 3 2 Getting Started 3 3 Classes 4 3.1 Features.............................................. 4 3.2 Inheritance............................................
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219
Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing
Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages
Introduction Compiler esign CSE 504 1 Overview 2 3 Phases of Translation ast modifled: Mon Jan 28 2013 at 17:19:57 EST Version: 1.5 23:45:54 2013/01/28 Compiled at 11:48 on 2015/01/28 Compiler esign Introduction
Exercise 4 Learning Python language fundamentals
Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also
Functional Programming
FP 2005 1.1 3 Functional Programming WOLFRAM KAHL [email protected] Department of Computing and Software McMaster University FP 2005 1.2 4 What Kinds of Programming Languages are There? Imperative telling
Chapter 15 Functional Programming Languages
Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,
COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19
Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4
Java Server Pages and Java Beans
Java Server Pages and Java Beans Java server pages (JSP) and Java beans work together to create a web application. Java server pages are html pages that also contain regular Java code, which is included
CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
CSCI 3136 Principles of Programming Languages
CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer
Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
Data Integration through XML/XSLT. Presenter: Xin Gu
Data Integration through XML/XSLT Presenter: Xin Gu q7.jar op.xsl goalmodel.q7 goalmodel.xml q7.xsl help, hurt GUI +, -, ++, -- goalmodel.op.xml merge.xsl goalmodel.input.xml profile.xml Goal model configurator
Fun with Phantom Types
1 Fun with Phantom Types RALF HINZE Institut für Informatik III, Universität Bonn Römerstraße 164, 53117 Bonn, Germany Email: [email protected] Homepage: http://www.informatik.uni-bonn.de/~ralf
Resco Mobile CRM Woodford (Rules Guide) Document version 6.2.0.0
Resco Mobile CRM Woodford (Rules Guide) Document version 6.2.0.0 Resco.net 1 Form Rules... 2 2 Steps... 2 2.1 Function Step... 2 2.1.1 Selecting Variable, Use of the Property Selector... 3 2.1.2 Function
Chapter 6: Programming Languages
Chapter 6: Programming Languages Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Copyright 2012 Pearson Education, Inc. Chapter 6: Programming Languages 6.1 Historical Perspective
Absolute Value Equations and Inequalities
Key Concepts: Compound Inequalities Absolute Value Equations and Inequalities Intersections and unions Suppose that A and B are two sets of numbers. The intersection of A and B is the set of all numbers
AP Computer Science A 2004 Free-Response Questions
AP Computer Science A 2004 Free-Response Questions The materials included in these files are intended for noncommercial use by AP teachers for course and exam preparation; permission for any other use
Syntax Check of Embedded SQL in C++ with Proto
Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, 2010. Vol. 2. pp. 383 390. Syntax Check of Embedded SQL in C++ with Proto Zalán Szűgyi, Zoltán Porkoláb
Single Page Web App Generator (SPWAG)
Single Page Web App Generator (SPWAG) Members Lauren Zou (ljz2112) Aftab Khan (ajk2194) Richard Chiou (rc2758) Yunhe (John) Wang (yw2439) Aditya Majumdar (am3713) Motivation In 2012, HTML5 and CSS3 took
CASCADING IF-ELSE. Cascading if-else Semantics. What the computer executes: What is the truth value 1? 3. Execute path 1 What is the truth value 2?
CASCADING IF-ELSE A cascading if- is a composite of if- statements where the false path of the outer statement is a nested if- statement. The nesting can continue to several levels. Cascading if- Syntax
Chapter 8 Selection 8-1
Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
Programming Database lectures for mathema
Programming Database lectures for mathematics students April 25, 2015 Functions Functions are defined in Postgres with CREATE FUNCTION name(parameter type,...) RETURNS result-type AS $$ function-body $$
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Parameter passing in LISP
Parameter passing in LISP The actual parameters in a function call are always expressions, represented as lists structures. LISP provides two main methods of parameter passing: Pass/Call-by-value. The
Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08)
Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08) The if statements of the previous chapters ask simple questions such as count
While Loop. 6. Iteration
While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true
