FizzBuzzinHaskell by embeddingadsl

Size: px
Start display at page:

Download "FizzBuzzinHaskell by embeddingadsl"

Transcription

1 FizzBuzzinHaskell by embeddingadsl Maciej Piróg Leuven Haskell User Group 24 May 2016

2 Players generally sit in a circle. The player designated to go first says the number 1, and each player thenceforth counts one number in turn. However, any number divisible by three is replaced by the word fizz and any divisible by five by the word buzz. Numbers divisible by both become fizzbuzz. A player who hesitates or makes a mistake is eliminated from the game. (Wikipedia) We solve the problem for a single n. Input: A natural naumber n. Output: fizz, buzz, fizzbuzz, or n.

3 Program A: fizzbuzz :: Int String fizzbuzz n = if n mod 3 == 0 n mod 5 == 0 then "fizzbuzz" else if n mod 3 == 0 then "fizz" else if n mod 5 == 0 then "buzz" else show n modularity information flow = control flow

4 Program B: fizzbuzz :: Int String fizzbuzz n = if n mod 3 == 0 then "fizz" ++ if n mod 5 == 0 then "buzz" else "" else if n mod 5 == 0 then "buzz" else show n modularity information flow = control flow

5 Program C: ( ) :: String String String "" s = s a s = a fizzbuzz :: Int String fizzbuzz n = ( ( if n mod 3 == 0 then "fizz" else "") ++ if n mod 5 == 0 then "buzz" else "") show n modularity information flow = control flow

6 Program D:? modularity information flow = control flow

7 So many ways to write FizzBuzz. Too many, maybe?

8 Dijkstra in A Discipline of Programming introduces an imperative language with only two instructions: Skip an idle instruction, it does nothing at all Halt stops the execution of the program

9 Enter the Skip Halt Print language We extend Dijkstra s language with an additional construct that allows us to print stuff out. For example, the program Print "hello" ; Skip ; Halt ; Print "world" prints out the string hello.

10 We implement Skip Halt Print in Haskell: data Cmd= Skip Halt Print String type Program = [Cmd] interp :: Program String interp (Skip : xs) = interp xs interp (Halt : xs) = "" interp (Print s : xs) = s ++ interp xs interp [ ] = ""

11 NO, we cannot write a program that solves FizzBuzz in SHP, and that is for many reasons (no input, no conditional execution, no operations on numbers). INSTEAD, for each n, we will write an SHP program that solves FizzBuzz for n, and then we interpret this program.

12 We build SHP programs out of one hole contexts, that is, programs with placeholders: Skip ; Print "hello" ; ; Print "world" We can insert a program (say, Print "cruel") into the hole: Skip ; Print "hello" ; Print "cruel" ; Print "world" or compose with another context (say, Skip ; ; Halt): Skip ; Print "hello" ; Skip ; ; Halt; Print "world" We use Higher-Order Abstract Syntax to represent contexts in Haskell!

13 An SHP program that solves FB for a given n: type Context = Program Program fizz, buzz, base :: Int Context fizz n n mod 3 == 0 = λx [Print "fizz" ] ++ x ++ [Halt] otherwise = λx x buzz n n mod 5 == 0 = λx [Print "buzz" ] ++ x ++ [Halt] otherwise = λx x base n = λx x ++ [Print (show n)] fb :: Int Program fb n = (base n fizz n buzz n) [Skip] fizzbuzz :: Int String fizzbuzz n = interp (fb n)

14 For example: fb 1 = [Skip, Print 1 ] fb 3 = [Print "fizz", Skip, Halt, Print 3 ] fb 5 = [Print "buzz", Skip, Halt, Print 5 ] fb 15 = [Print "fizz", Print "buzz", Skip, Halt, Halt, Print 15 ]

15 Let s perform some program calculation...

16 interp is a fold: step :: Cmd String String step Skip xs = xs step Halt xs = "" step (Print s) xs = s ++ xs interp :: Program String interp = foldr step ""

17 Some program calculation: interp [Print "c", Halt, Skip] = foldr step "" [Print "c", Halt, Skip] = foldr ( ) id [step (Print "c"), step Halt, step Skip] "" = foldr ( ) id [("c" ++), const "", id] "" = (("c" ++) (const "") id) ""

18 An SHP program that solves FB for a given n, again: type Context = Program Program fizz, buzz, base :: Int Context fizz n n mod 3 == 0 = λx [Print "fizz" ] ++ x ++ [Halt] otherwise = λx x buzz n n mod 5 == 0 = λx [Print "buzz" ] ++ x ++ [Halt] otherwise = λx x base n = λx x ++ [Print (show n)] fb :: Int Program fb n = (base n fizz n buzz n) [Skip] fizzbuzz :: Int String fizzbuzz n = interp (fb n)

19 It is transformed into: type Program = String String type Context = Program Program fizz, buzz, base :: Int Context fizz n n mod 3 == 0 = λx ("fizz" ++) x (const "") otherwise = id buzz n n mod 5 == 0 = λx ("buzz" ++) x (const "") otherwise = id base n = λx x ++ [Print (show n)] fizzbuzz :: Int String fizzbuzz n = (base n fizz n buzz n) ""

20 Make auxiliary functions local definitions + more inlining: fizzbuzz :: Int String fizzbuzz n = (fizz buzz) id (show n) where fizz n mod 3 == 0 = λx const ("fizz" ++ x "") otherwise = id buzz n mod 5 == 0 = λx const ("buzz" ++ x "") otherwise = id

21 We abstract over fizzing and buzzing: fizzbuzz :: Int String fizzbuzz n = (test 3 "fizz" test 5 "buzz") id (show n) where test d s x n mod d == 0 = const (s ++ x "") otherwise = x type of test? test :: Int String (String String) String String

22 We abstract over fizzing and buzzing: fizzbuzz :: Int String fizzbuzz n = (test 3 "fizz" test 5 "buzz") id (show n) where test d s x v n mod d == 0 = s ++ x "" otherwise = x v type of test? test :: Int String (String String) String String

23 Takeaway FizzBuzz is not simple at all. Meaning, we can have some fun even with such a simple problem. But will I get a job? Higher-order functions are your tool to express advanced control flow. Details in the paper FizzBuzz in Haskell by embedding a domain-specific language. The Monad.Reader 23:7-16, T&Q?

24 THE END

Maar hoe moet het dan?

Maar hoe moet het dan? Maar hoe moet het dan? Onderzoek naar feedback in interactieve leeromgevingen bij de Faculteit Informatica Johan Jeuring Met bijdragen van Alex Gerdes, Bastiaan Heeren, Josje Lodder, Harrie Passier, Sylvia

More information

UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions.

UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions. UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING Answer THREE Questions. The Use of Electronic Calculators: is NOT Permitted. -1- Answer Question

More information

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

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

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

Programming Languages

Programming Languages Programming Languages Qing Yi Course web site: www.cs.utsa.edu/~qingyi/cs3723 cs3723 1 A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office:

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

Introduction to Java

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

More information

ADVENTURES IN COINS RATIONALE FOR ADVENTURE TAKEAWAYS FOR CUB SCOUTS ADVENTURE REQUIREMENTS. Wolf Handbook, page 124

ADVENTURES IN COINS RATIONALE FOR ADVENTURE TAKEAWAYS FOR CUB SCOUTS ADVENTURE REQUIREMENTS. Wolf Handbook, page 124 CHARACTER CHARACTER CHARACTER CHARACTER ADVENTURES IN COINS RATIONALE FOR ADVENTURE Coins are more than just money. In this adventure, Wolves will learn how to spot the various markings on a coin and identify

More information

MPLAB X + CCS C Compiler Tutorial

MPLAB X + CCS C Compiler Tutorial MPLAB X + CCS C Compiler Tutorial How to install the CCS C Compiler inside MPLAB X Before the CCS C Compiler can be used inside MPLAB X, the CCS C MPLAB X Plug-in must be installed. This process can be

More information

A Sane Approach to Modern Web Application Development. Adam Chlipala February 22, 2010

A Sane Approach to Modern Web Application Development. Adam Chlipala February 22, 2010 A Sane Approach to Modern Web Application Development Adam Chlipala February 22, 2010 1 Web 1.0 Application Hello world! 2 Forms blah This field is called name. Page Name:

More information

Special Directions for this Test

Special Directions for this Test 1 Spring, 2013 Name: (Please do not write your id number!) COP 4020 Programming Languages I Test on Haskell and Functional Programming Special Directions for this Test This test has 7 questions and pages

More information

Functional Programming in C++11

Functional Programming in C++11 Functional Programming in C++11 science + computing ag IT-Dienstleistungen und Software für anspruchsvolle Rechnernetze Tübingen München Berlin Düsseldorf An Overview Programming in a functional style

More information

Advanced Functional Programming (9) Domain Specific Embedded Languages

Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages, Universiteit Utrecht http://www.cs.uu.nl/groups/st/ February

More information

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014 CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections

More information

Welcome to Introduction to programming in Python

Welcome to Introduction to programming in Python Welcome to Introduction to programming in Python Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 14, Jan 21, Jan 28, Feb 11 Welcome Fire exits Toilets Refreshments 1 Learning objectives of the course An

More information

Colored Hats and Logic Puzzles

Colored Hats and Logic Puzzles Colored Hats and Logic Puzzles Alex Zorn January 21, 2013 1 Introduction In this talk we ll discuss a collection of logic puzzles/games in which a number of people are given colored hats, and they try

More information

Programming and Reasoning with Algebraic Effects and Dependent Types

Programming and Reasoning with Algebraic Effects and Dependent Types Programming and Reasoning with Algebraic Effects and Dependent Types Edwin C. Brady School of Computer Science, University of St Andrews, St Andrews, Scotland. Email: ecb10@st-andrews.ac.uk Abstract One

More information

Let s begin. Great breakout on volume maybe we hold until the target is hit maybe we don t it depends on the overall market.

Let s begin. Great breakout on volume maybe we hold until the target is hit maybe we don t it depends on the overall market. Day Trading vs. Swing Trading by ChartSpeak Sunday, August 1, 2004 ---------------------------------------------------------------------------------------------------------------------------------------------------------------

More information

Google s MapReduce Programming Model Revisited

Google s MapReduce Programming Model Revisited Google s MapReduce Programming Model Revisited Ralf Lämmel Data Programmability Team Microsoft Corp. Redmond, WA, USA Abstract Google s MapReduce programming model serves for processing large data sets

More information

Gluing things together with Haskell. Neil Mitchell http://nmitchell.co.uk/

Gluing things together with Haskell. Neil Mitchell http://nmitchell.co.uk/ Gluing things together with Haskell Neil Mitchell http://nmitchell.co.uk/ Code Elegantly designed Build system Test harness Continuous integration Release bundling Installer generator Release distribution

More information

Course Intro Instructor Intro Java Intro, Continued

Course Intro Instructor Intro Java Intro, Continued Course Intro Instructor Intro Java Intro, Continued The syllabus Java etc. To submit your homework, do Team > Share Your repository name is csse220-200830-username Use your old SVN password. Note to assistants:

More information

Icebreaker: Fantastic Four

Icebreaker: Fantastic Four Icebreaker: Fantastic Four 1. Break the group into groups of 4. 2. Each team must come up with four things that they all have in common. They may be as simple or as complex as they want (example: we all

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs 1 The Universal Machine n A computer -- a machine that stores and manipulates information under the control of a

More information

Programming Fundamentals. Lesson 20 Sections

Programming Fundamentals. Lesson 20 Sections Programming Fundamentals Lesson 20 Sections Today, we will Study sections, in Haskell. Sections are another class of expressions that represent functions. A section is a binary operation where one of the

More information

MapReduce (in the cloud)

MapReduce (in the cloud) MapReduce (in the cloud) How to painlessly process terabytes of data by Irina Gordei MapReduce Presentation Outline What is MapReduce? Example How it works MapReduce in the cloud Conclusion Demo Motivation:

More information

Working Agreements Jane Haskell, Extension Professor

Working Agreements Jane Haskell, Extension Professor Page 1 of 5 Working Agreements Jane Haskell, Extension Professor When people meet in groups, there generally are agreements about how interactions between the group members will happen. These agreements

More information

Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

More information

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016 Master s Degree Course in Computer Engineering Formal Languages FORMAL LANGUAGES AND COMPILERS Lexical analysis Floriano Scioscia 1 Introductive terminological distinction Lexical string or lexeme = meaningful

More information

Sources: On the Web: Slides will be available on:

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,

More information

Massachusetts Comprehensive Assessment System Practice Test English Language Arts Reading Comprehension GRADE 6

Massachusetts Comprehensive Assessment System Practice Test English Language Arts Reading Comprehension GRADE 6 Massachusetts Comprehensive Assessment System Practice Test English Language Arts Reading Comprehension GRADE 6 Student Name School Name District Name This is a practice test. Your responses to practice

More information

Introduction to: Computers & Programming: Review for Midterm 2

Introduction to: Computers & Programming: Review for Midterm 2 Introduction to: Computers & Programming: Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in the Class The Practice Midterm

More information

Comp151. Definitions & Declarations

Comp151. Definitions & Declarations Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

More information

Computer Science at Kent

Computer Science at Kent Computer Science at Kent Transformation in HaRe Chau Nguyen-Viet Technical Report No. 21-04 December 2004 Copyright 2004 University of Kent Published by the Computing Laboratory, University of Kent, Canterbury,

More information

Chapter 15 Functional Programming Languages

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,

More information

PIC 10A. Lecture 7: Graphics II and intro to the if statement

PIC 10A. Lecture 7: Graphics II and intro to the if statement PIC 10A Lecture 7: Graphics II and intro to the if statement Setting up a coordinate system By default the viewing window has a coordinate system already set up for you 10-10 10-10 The origin is in the

More information

Activities for parents to support the learning of multiplication tables

Activities for parents to support the learning of multiplication tables Activities for parents to support the learning of multiplication tables There are many times table games available on line which will help children to recall times tables and division facts. You can also

More information

1998. (R. Bird and P. Wadler, Introduction to Functional Programming, Prentice

1998. (R. Bird and P. Wadler, Introduction to Functional Programming, Prentice Mathematical Structures in Programs 15 Algebra) The Shorter Oxford English Dictionary): the reunion of broken parts a calculus of symbols combined according to defined laws Haskell 3 4 Richard Bird. Introduction

More information

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs Objectives Introduction to the class Why we program and what that means Introduction to the Python programming language

More information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

IEEEXTREME PROGRAMMING COMPETITION PROBLEM & INSTRUCTION BOOKLET #3

IEEEXTREME PROGRAMMING COMPETITION PROBLEM & INSTRUCTION BOOKLET #3 IEEEXTREME PROGRAMMING COMPETITION 2008 PROBLEM & INSTRUCTION BOOKLET #3 Instructions Read all the problems carefully. Each of the problems has a problem number (shown on top), a title, an approximate

More information

Fun for all the Family 3- Quite a few games for articles and determiners

Fun for all the Family 3- Quite a few games for articles and determiners Fun for all the Family 3- Quite a few games for articles and determiners Articles in English is one of those grammar points that are fairly easy to explain the fundamentals of, but even Advanced learners

More information

Résumé Writing Made Easy!

Résumé Writing Made Easy! Résumé Writing Made Easy! INCLUDES 6 job-winning, Fully Editable Model Résumés & Templates Skip Freeman Professional 'Headhunter' Contents The Legal Stuff Taking the STRESS Out of Resume Writing! 13 Resume

More information

The Fruit of the Spirit is Love

The Fruit of the Spirit is Love The Fruit of the Spirit is Love Pre-Session Warm Up (Galatians 5:22-23) Today we are going to learn more about the fruit of the Spirit called, Love. What do you think of when you hear the word love? A

More information

C++ Input/Output: Streams

C++ Input/Output: Streams C++ Input/Output: Streams 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: istream

More information

Lab Experience 17. Programming Language Translation

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

More information

SENTENCE PUZZLE RACE. by Zoltan Golcz

SENTENCE PUZZLE RACE. by Zoltan Golcz SENTENCE PUZZLE RACE by Zoltan Golcz Teacher s Notes Level: absolute beginners (can be adapted to suit any levels) Aim: revise vocabulary, word order and sentence structures (+,-,?) Grouping: pair work/teams

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

Regression Verification: Status Report

Regression Verification: Status Report Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22 Introduction How to prevent regressions in software

More information

HPCC - Hrothgar Getting Started User Guide MPI Programming

HPCC - Hrothgar Getting Started User Guide MPI Programming HPCC - Hrothgar Getting Started User Guide MPI Programming High Performance Computing Center Texas Tech University HPCC - Hrothgar 2 Table of Contents 1. Introduction... 3 2. Setting up the environment...

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

How to modify a car starter for forward/reverse operation

How to modify a car starter for forward/reverse operation How to modify a car starter for forward/reverse operation Ok, start by choosing a starter. I took a starter out of an older style Nissan Sentra. I chose this particular starter for two reasons: 1. It was

More information

Chapter 2. Making Shapes

Chapter 2. Making Shapes Chapter 2. Making Shapes Let's play turtle! You can use your Pencil Turtle, you can use yourself, or you can use some of your friends. In fact, why not try all three? Rabbit Trail 4. Body Geometry Can

More information

TEST-TAKING STRATEGIES FOR READING

TEST-TAKING STRATEGIES FOR READING TEST-TAKING STRATEGIES FOR READING For students who have enrolled in this class shortly before taking the reading proficiency exam, here are some helpful test-taking strategies you can use: 1. Always read

More information

Deterministic Discrete Modeling

Deterministic Discrete Modeling Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste

More information

Game Programming & Game Design

Game Programming & Game Design Unit 11: Game Programming & Game Design BRIDGES TO COMPUTING http://bridges.brooklyn.cuny.edu College Now, Bridges to Computing Page 1 Topic Descriptions and Objectives Unit 7: Game Programming & Game

More information

Computer Science for San Francisco Youth

Computer Science for San Francisco Youth Python for Beginners Python for Beginners Lesson 0. A Short Intro Lesson 1. My First Python Program Lesson 2. Input from user Lesson 3. Variables Lesson 4. If Statements How If Statements Work Structure

More information

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes Computer Systems II Creating and Executing Processes 1 Unix system calls fork( ) wait( ) exit( ) 2 How To Create New Processes? Underlying mechanism - A process runs fork to create a child process - Parent

More information

Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13

Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13 Invitation to Ezhil: A Tamil Programming Language for Early Computer-Science Education Abstract: Muthiah Annamalai, Ph.D. Boston, USA. Ezhil is a Tamil programming language with support for imperative

More information

Probability Investigations

Probability Investigations 2011 Math Solutions 1 2011 Math Solutions 2 2011 Math Solutions 3 As I was preparing to think about those routines that we have in place in our classrooms or want to put in place in our classrooms, I decided

More information

Denotational design with type class morphisms (extended version)

Denotational design with type class morphisms (extended version) LambdaPix technical report 2009-01, March 2009 (minor revisions February 15, 2011) 1 Denotational design with type class morphisms (extended version) Conal Elliott LambdaPix conal@conal.net Abstract Type

More information

Report on the Train Ticketing System

Report on the Train Ticketing System Report on the Train Ticketing System Author: Zaobo He, Bing Jiang, Zhuojun Duan 1.Introduction... 2 1.1 Intentions... 2 1.2 Background... 2 2. Overview of the Tasks... 3 2.1 Modules of the system... 3

More information

CSc 372. Comparative Programming Languages. 21 : Haskell Accumulative Recursion. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 21 : Haskell Accumulative Recursion. Department of Computer Science University of Arizona 1/18 CSc 372 Comparative Programming Languages 21 : Haskell Accumulative Recursion Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/18 Stack

More information

PHP MySQL vs. Unity. Introduction. The PHP side. The Unity side

PHP MySQL vs. Unity. Introduction. The PHP side. The Unity side PHP MySQL vs. Unity Introduction When using the Unity game engine, there are methods to connect your game to a MySQL database over the internet. The easiest way is to use JavaScript and PHP, especially

More information

GROUP GAMES Keeper of the keys: Duck duck goose: Shoe bomb:

GROUP GAMES Keeper of the keys: Duck duck goose: Shoe bomb: GROUP GAMES This booklet is designed to help you play games in your settings. It has a list of games that can be played in large and small groups and games that can be played indoors and outdoors. GROUP

More information

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling Form Validation Server-side Web Development and Programming Lecture 7: Input Validation and Error Handling Detecting user error Invalid form information Inconsistencies of forms to other entities Enter

More information

15-150 Lecture 11: Tail Recursion; Continuations

15-150 Lecture 11: Tail Recursion; Continuations 15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail

More information

CrownPeak Playbook CrownPeak Hosting with PHP

CrownPeak Playbook CrownPeak Hosting with PHP CrownPeak Playbook CrownPeak Hosting with PHP Version 1.0 2014, Inc. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical,

More information

Introduction to Lex. General Description Input file Output file How matching is done Regular expressions Local names Using Lex

Introduction to Lex. General Description Input file Output file How matching is done Regular expressions Local names Using Lex Introduction to Lex General Description Input file Output file How matching is done Regular expressions Local names Using Lex General Description Lex is a program that automatically generates code for

More information

Variable Base Interface

Variable Base Interface Chapter 6 Variable Base Interface 6.1 Introduction Finite element codes has been changed a lot during the evolution of the Finite Element Method, In its early times, finite element applications were developed

More information

C# and Other Languages

C# and Other Languages C# and Other Languages Rob Miles Department of Computer Science Why do we have lots of Programming Languages? Different developer audiences Different application areas/target platforms Graphics, AI, List

More information

IBM Unica emessage Version 8 Release 6 February 13, 2015. User's Guide

IBM Unica emessage Version 8 Release 6 February 13, 2015. User's Guide IBM Unica emessage Version 8 Release 6 February 13, 2015 User's Guide Note Before using this information and the product it supports, read the information in Notices on page 403. This edition applies to

More information

Prime Time: Homework Examples from ACE

Prime Time: Homework Examples from ACE Prime Time: Homework Examples from ACE Investigation 1: Building on Factors and Multiples, ACE #8, 28 Investigation 2: Common Multiples and Common Factors, ACE #11, 16, 17, 28 Investigation 3: Factorizations:

More information

TouchDevelop App Development on Mobile Devices

TouchDevelop App Development on Mobile Devices TouchDevelop App Development on Mobile Devices Nikolai Tillmann, Michal Moskal, Jonathan de Halleux, Manuel Fahndrich, Sebastian Burckhardt Microsoft Research One Microsoft Way Redmond WA, USA {nikolait,micmo,jhalleux,maf,sburckha}@microsoft.com

More information

Programming Languages

Programming Languages CS 345 Programming Languages Vitaly Shmatikov http://www.cs.utexas.edu/~shmat/courses/cs345/ slide 1 Course Personnel Instructor: Vitaly Shmatikov Office: CSA 1.114 Office hours: Tuesday, 3:30-4:30pm (after

More information

1 Hour, Closed Notes, Browser open to Java API docs is OK

1 Hour, Closed Notes, Browser open to Java API docs is OK CSCI 143 Exam 2 Name 1 Hour, Closed Notes, Browser open to Java API docs is OK A. Short Answer For questions 1 5 credit will only be given for a correct answer. Put each answer on the appropriate line.

More information

Brain Game. 3.4 Solving and Graphing Inequalities HOW TO PLAY PRACTICE. Name Date Class Period. MATERIALS game cards

Brain Game. 3.4 Solving and Graphing Inequalities HOW TO PLAY PRACTICE. Name Date Class Period. MATERIALS game cards Name Date Class Period Brain Game 3.4 Solving and Graphing Inequalities MATERIALS game cards HOW TO PLAY Work with another student. Shuffle the cards you receive from your teacher. Then put them face down

More information

HOW TO PLAY WINNER S CIRCLE REWARDS MEMBERSHIP REQUIRED TO PLAY. IS YOUR GAME READY FOR A NEW CHALLENGE? THE TRADITIONAL GAME WITH A MODERN TWIST

HOW TO PLAY WINNER S CIRCLE REWARDS MEMBERSHIP REQUIRED TO PLAY. IS YOUR GAME READY FOR A NEW CHALLENGE? THE TRADITIONAL GAME WITH A MODERN TWIST HOW TO PLAY WINNER S CIRCLE REWARDS MEMBERSHIP REQUIRED TO PLAY. IS YOUR GAME READY FOR A NEW CHALLENGE? THE TRADITIONAL GAME WITH A MODERN TWIST VISIT FOR MORE GAME DETAILS INTRODUCTION Electronic Texas

More information

Lab 11. Simulations. The Concept

Lab 11. Simulations. The Concept Lab 11 Simulations In this lab you ll learn how to create simulations to provide approximate answers to probability questions. We ll make use of a particular kind of structure, called a box model, that

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search Chapter Objectives Chapter 9 Search Algorithms Data Structures Using C++ 1 Learn the various search algorithms Explore how to implement the sequential and binary search algorithms Discover how the sequential

More information

Lecture 2 Notes: Flow of Control

Lecture 2 Notes: Flow of Control 6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The

More information

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies: Exercise 0 Deadline: None Computer Setup Windows Download Python(x,y) via http://code.google.com/p/pythonxy/wiki/downloads and install it. Make sure that before installation the installer does not complain

More information

Introduction to Programming (in C++) Sorting. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Sorting. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Introduction to Programming (in C++) Sorting Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Sorting Let elem be a type with a operation, which is a total order A vector

More information

AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES

AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES Question 4: Game Design (Design) Part A: RandomPlayer 4 points +1/2 class RandomPlayer extends Player +1 constructor +1/2 public RandomPlayer(String aname)

More information

Monads for functional programming

Monads for functional programming Monads for functional programming Philip Wadler, University of Glasgow Department of Computing Science, University of Glasgow, G12 8QQ, Scotland (wadler@dcs.glasgow.ac.uk) Abstract. The use of monads to

More information

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach. DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER Purpose: The purpose of this tutorial is to develop a java web service using a top-down approach. Topics: This tutorial covers the following topics:

More information

The Advanced Guide to Youtube Video SEO

The Advanced Guide to Youtube Video SEO The Advanced Guide to Youtube Video SEO Tips and Techniques Part 1 by: Video Optimize 1. Youtube Channel The difference between a Youtube Channel that s brand new versus one that is 1 year old is really

More information

The countdown problem

The countdown problem JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON

More information

Codey likes playing video games...

Codey likes playing video games... Codey likes playing video games... Codey likes playing video games and usually is playing under her desk instead of paying attention in class. She doesn t understand the point of the math worksheet and

More information

WHAT I WANT FROM TREATMENT (2.0) William R. Miller & Janice M. Brown

WHAT I WANT FROM TREATMENT (2.0) William R. Miller & Janice M. Brown CASAA Research Division* WHAT I WANT FROM TREATMENT (.) William R. Miller & Janice M. Brown INSTRUCTIONS FOR OFFICE USE ONLY Study ID Point Date Raid WIWOOO- Revised 8/94 5 Pages People have different

More information

Origin Tracking in Attribute Grammars

Origin Tracking in Attribute Grammars Origin Tracking in Attribute Grammars Kevin Williams and Eric Van Wyk University of Minnesota Stellenbosch, WG2.11, January 20-22, 2015 1 / 37 First, some advertising Multiple new faculty positions at

More information

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. 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

More information

Turing Machines, Busy Beavers, and Big Questions about Computing

Turing Machines, Busy Beavers, and Big Questions about Computing Turing Machines, usy eavers, and ig Questions about Computing My Research Group Computer Security: computing in the presence of adversaries Last summer student projects: Privacy in Social Networks (drienne

More information

But have you ever wondered how to create your own website?

But have you ever wondered how to create your own website? Foreword We live in a time when websites have become part of our everyday lives, replacing newspapers and books, and offering users a whole range of new opportunities. You probably visit at least a few

More information

Hooray for the Hundreds Chart!!

Hooray for the Hundreds Chart!! Hooray for the Hundreds Chart!! The hundreds chart consists of a grid of numbers from 1 to 100, with each row containing a group of 10 numbers. As a result, children using this chart can count across rows

More information

Idea 1: Idea 2: Idea 1: Idea 2: Idea 3: Idea 4:

Idea 1: Idea 2: Idea 1: Idea 2: Idea 3: Idea 4: WHAT Idea 1: Use a barrier (bag, box) to hide materials of the activity from view. Talk about the fun things in the bag/box. If necessary, let the person hear/feel that there is stuff in there. Idea 2:

More information

Passing 1D arrays to functions.

Passing 1D arrays to functions. Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,

More information

Semantic Checker (Part I)

Semantic Checker (Part I) Semantic Checker (Part I) Now, the coding (and the fun) begins. Your Parser fix: parser integration main statements i/o statments don't worry about: error recovery (possibly stripping those rules out)

More information