COMPUTER SCIENCE 123. Foundations of Computer Science. 5. Strings
|
|
- Bertina O’Neal’
- 6 years ago
- Views:
Transcription
1 COMPUTER SCIENCE 123 Foundations of Computer Science 5. Strings Summary: This lecture introduces strings in Haskell. You should also have: Tutorial sheet 2 Solutions to Tutorial sheet 1 Lab sheet 3 Solutions to Lab sheet 2 Reference: Thompson Chapter 5 covers the next few lectures R.L. While,
2 Strings The structured data type String contains values that consist of a sequence of zero or more Chars for example "Mississippi" a typical alphabetic string "42" a string of digits "99(!) red balloons." a mixed string " " a string of three spaces "" the empty string Note in particular the difference between 'q' "q" a Char a String containing one Char the difference between "" the empty String " " a String containing one (space) Char " " a String containing two (space) Chars etc. the difference between 42 an Int "42" a String containing two (digit) Chars the difference between 7 an Int '7' a Char "7" a String containing one (digit) Char cs123 Foundations of CS 1 of Strings
3 Syntax of names and values Make sure that you understand the difference between these three functions f :: Int -> Int -- f n returns a number f n = n g :: Int -> Char -- g n returns a character g n = 'n' h :: Int -> String -- h n returns a string h n = "n" cs123 Foundations of CS 2 of Strings
4 String indexing We can access the individual elements of a string using the built-in infix operator!!!! :: String -> Int -> Char -- pre: 0 <= k < length s -- s!! k returns the k th element of s -- (indexing from 0) For example: "Mississippi"!! 0 == 'M' "Mississippi"!! 1 == 'i' "Mississippi"!! 10 == 'i' Note the pre-condition on!!: "Mississippi"!! (-1) "Mississippi"!! 11 is illegal is illegal in particular ""!! k is illegal for all k cs123 Foundations of CS 3 of Strings
5 String operations Operations available on strings include the following null tells us if its argument is empty null :: String -> Bool -- null s returns True iff s is empty for example null "Mississippi" == False null "" == True length tells us how many elements its argument has length :: String -> Int -- length s returns the number of -- elements in s for example length "Mississippi" == 11 length "" == 0 ++ (infix) performs list concatenation ++ :: String -> String -> String -- xs ++ ys returns a String containing -- the elements of xs followed by -- the elements of ys for example "Mississippi" ++ "River" == "MississippiRiver" "WA" ++ "les" == "WAles" "" ++ "life" == "life" "life" ++ "" == "life" cs123 Foundations of CS 4 of Strings
6 String operations contd. \\ (infix) performs list difference \\ :: String -> String -> String -- xs \\ ys returns a String containing -- the elements of xs, but with the -- first occurrence of each element -- of ys removed for example "Mississippi River" \\ "sips" == "Missipi River" "" \\ "River" == "" \\ is defined in the module List : (pronounced "cons", infix) performs list "addition" : :: Char -> String -> String -- x : xs returns a String containing -- x followed by the elements of xs for example '4' : "Mississippi" == "4Mississippi" '4' : "" == "4" reverse reverses its argument reverse :: String -> String -- reverse s returns a string containing -- the elements of s in reverse order for example reverse "Mississippi" == "ippississim" reverse "12 of us" == "su fo 21" reverse "" == "" cs123 Foundations of CS 5 of Strings
7 String comparison Remember that the relational operators can be used to compare any two values of the same type Two strings are equal iff they contain exactly the same elements in exactly the same order Ordering comparisons on strings are decided on lexicographical ordering for letters, dictionary ordering again, based on the ASCII representation of Chars For example "Alison" < "Lyndon" "Alison" < "Alix" A string precedes all strings of which it is a prefix "Ali" < "Alison" "" < "Ali" in fact "" < s for all non-empty s All upper-case letters precede all lower-case letters "Zimm" < "ali" "ali G" < "ali g" cs123 Foundations of CS 6 of Strings
8 Precedence and associativity Operator Precedence Associativity New?!! 9 left ^ 8 right * 7 left `div`, `mod`, / 7 left +, - 6 left ++, : 5 right \\ 5 none all relationals 4 && 3 right 2 right Note the associativities of : and ++ (x:y):zs /= x:y:zs == x:(y:zs) (xs++y):zs /= xs++y:ys == xs++(y:ys) cs123 Foundations of CS 7 of Strings
9 Examples Consider the function middlechar that returns the middle element of a non-empty string middlechar :: String -> Char -- pre: not (null s) -- middlechar s returns the -- middle element of s middlechar s not (null s) = s!! (length s `div` 2) note that: middlechar "abcde" == 'c' middlechar "abcd" == 'c' can you define premiddlechar, such that premiddlechar "abcde" == 'c' premiddlechar "abcd" == 'b' Consider the function subset that tells us whether one string s is a subset of another string s' s is a subset of s' if all of the elements of s are also elements of s' assume for simplicity that s has no duplicated elements subset :: String -> String -> Bool -- pre: s has no duplicated elements -- subset s s' returns True iff all of the -- elements of s are also elements of s' subset s s' = null (s \\ s') can you define a more general function subsetgen that lifts the pre-condition? cs123 Foundations of CS 8 of Strings
10 show The function show can be applied to a value of almost any type and turns it into a string for example show 35 == "35" show (-35) == "-35" show True == "True" show 'w' == "'w'" Things get a little complicated when show is applied to a string show "A" show (show 'w') == "\"A\"" == "\"'w'\"" Here the backslash is being used as an escape character, as discussed in Lecture 4 "\"A\"" contains three characters: double-quote, 'A', double-quote cs123 Foundations of CS 9 of Strings
11 Example Consider the function showmonth that turns a month into a string showmonth :: Int -> String -- pre: 1 <= m <= showmonth m returns the name -- of the mth month showmonth m m == 1 = "January" m == 2 = "February" m == 3 = "March" m == 4 = "April" m == 5 = "May" m == 6 = "June" m == 7 = "July" m == 8 = "August" m == 9 = "September" m == 10 = "October" m == 11 = "November" m == 12 = "December" Consider the function suffix that returns the appropriate suffix for a year suffix :: Int -> String -- pre: y /= 0 -- suffix y returns the date suffix for y suffix y y < 0 = "BC" y > 0 = "AD" Consider the function showdate that turns a date into a string showdate :: Int -> Int -> Int -> String -- pre: y /= 0 && 1 <= m <= pre: 1 <= d <= number of days in m -- showmonth d m y returns the date d/m/y showdate d m y = show d ++ " " ++ showmonth m ++ " " ++ show (abs y) ++ suffix y cs123 Foundations of CS 10 of Strings
12 String output When an expression that returns a string is typed on the Hugs command-line, the string is displayed in doublequotes for example Prelude> "What now?" "What now?" (180 reductions, 257 cells) Prelude> reverse "What now?" "?won tahw" (195 reductions, 273 cells) Prelude> Structured output can be produced by including carriagereturns ('\n') in the string and by applying the function putstr on the command-line for example Prelude> "Bill" ++ "\nand\n" ++ "Ben" "Bill\nand\nBen" (246 reductions, 351 cells) Prelude> putstr ("Bill" ++ "\nand\n" ++ "Ben") Bill and Ben (17 reductions, 47 cells) Prelude> cs123 Foundations of CS 11 of Strings
02157 Functional Programming. Michael R. Ha. Disjoint Unions and Higher-order list functions. Michael R. Hansen
Disjoint Unions and Higher-order list functions nsen 1 DTU Compute, Technical University of Denmark Disjoint Unions and Higher-order list functions MRH 27/09/2018 Overview Recap Disjoint union (or Tagged
More information02157 Functional Programming Tagged values and Higher-order list functions
Tagged values and Higher-order list functions nsen 1 DTU Informatics, Technical University of Denmark Tagged values and Higher-order list functions MRH 27/09/2012 Part I: Disjoint Sets An Example A shape
More information02157 Functional Programming. Michael R. Ha. Tagged values and Higher-order list functions. Michael R. Hansen
Tagged values and Higher-order list functions nsen 1 DTU Compute, Technical University of Denmark Tagged values and Higher-order list functions MRH 3/10/2017 Overview Disjoint union (or Tagged Values)
More informationPROGRAMMING IN HASKELL. Chapter 5 - List Comprehensions
PROGRAMMING IN HASKELL Chapter 5 - List Comprehensions 0 Set Comprehensions In mathematics, the comprehension notation can be used to construct new sets from old sets. {x 2 x {1...5}} The set {1,4,9,16,25}
More informationArrays. What if you have a 1000 line file? Arrays
Arrays Chapter 8 page 477 11/8/06 CS150 Introduction to Computer Science 1 1 What if you have a 1000 line file? Read in the following file and print out a population graph as shown below. The maximum value
More informationExample. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review:
Following are three examples of calculations for MCP employees (undefined hours of work) and three examples for MCP office employees. Examples use the data from the table below. For your calculations use
More informationHaskell Scripts. Yan Huang
Haskell Scripts Yan Huang yh33@indiana.edu Last Quiz Objectives Writing Haskell programs in.hs files Note some differences between programs typed into GHCi and programs written in script files Operator
More informationRecursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions
Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin
More informationHaskell Introduction Lists Other Structures Data Structures. Haskell Introduction. Mark Snyder
Outline 1 2 3 4 What is Haskell? Haskell is a functional programming language. Characteristics functional non-strict ( lazy ) pure (no side effects*) strongly statically typed available compiled and interpreted
More informationCS 320: Concepts of Programming Languages
CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 04: Basic Haskell Continued o Polymorphic Types o Type Inference with Polymorphism o Standard
More informationCOMPUTER TRAINING CENTER
Excel 2007 Introduction to Spreadsheets COMPUTER TRAINING CENTER 1515 SW 10 th Avenue Topeka KS 66604-1374 785.580.4606 class@tscpl.org www.tscpl.org Excel 2007 Introduction 1 Office button Quick Access
More informationIntroduction to Programming, Aug-Dec 2006
Introduction to Programming, Aug-Dec 2006 Lecture 3, Friday 11 Aug 2006 Lists... We can implicitly decompose a list into its head and tail by providing a pattern with two variables to denote the two components
More informationHaskell through HUGS THE BASICS
Haskell through HUGS THE BASICS FP for DB Basic HUGS 1 Algorithmic Imperative Languages variables assignment if condition then action1 else action2 loop block while condition do action repeat action until
More informationSequential Search (Searching Supplement: 1-2)
(Searching Supplement: 1-2) A sequential search simply involves looking at each item in an array in turn until either the value being searched for is found or it can be determined that the value is not
More informationCITS3211 FUNCTIONAL PROGRAMMING. 7. Lazy evaluation and infinite lists
CITS3211 FUNCTIONAL PROGRAMMING 7. Lazy evaluation and infinite lists Summary: This lecture introduces lazy evaluation and infinite lists in functional languages. cs123 notes: Lecture 19 R.L. While, 1997
More informationITT8060: Advanced Programming (in F#)
based on slides by Michael R. Hansen ITT8060: Advanced Programming (in F#) Lecture 2: Identifiers, values, expressions, functions and types Juhan Ernits Department of Software Science, Tallinn University
More informationHighline Excel 2016 Class 09: Date Functions
Highline Excel 2016 Class 09: Date Functions Table of Contents Date Functions... 2 Examples of EOMONTH, EDATE and DATE functions:... 2 Fiscal Year... 3 Example of Data Set with Date Helper Columns, including
More informationRead and fill in this page now. Your lab section day and time: Name of the person sitting to your left: Name of the person sitting to your right:
CS3 Fall 04 Midterm 1 Read and fill in this page now Your name: Your login name: Your lab section day and time: Your lab T.A.: Name of the person sitting to your left: Name of the person sitting to your
More informationTREES Lecture 12 CS2110 Spring 2019
TREES Lecture 12 CS2110 Spring 2019 Announcements 2 Submit P1 Conflict quiz on CMS by end of day Wednesday. We won t be sending confirmations; no news is good news. Extra time people will eventually get
More informationCS 360: Programming Languages Lecture 10: Introduction to Haskell
CS 360: Programming Languages Lecture 10: Introduction to Haskell Geoffrey Mainland Drexel University Thursday, February 5, 2015 Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia
More informationPROGRAMMING 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 informationHaske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell
Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program
More informationLogical Methods in... using Haskell Getting Started
Logical Methods in... using Haskell Getting Started Jan van Eijck May 4, 2005 Abstract The purpose of this course is to teach a bit of functional programming and logic, and to connect logical reasoning
More informationAn introduction introduction to functional functional programming programming using usin Haskell
An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program
More informationStandard prelude. Appendix A. A.1 Classes
Appendix A Standard prelude In this appendix we present some of the most commonly used definitions from the standard prelude. For clarity, a number of the definitions have been simplified or modified from
More informationThe List Datatype. CSc 372. Comparative Programming Languages. 6 : Haskell Lists. Department of Computer Science University of Arizona
The List Datatype CSc 372 Comparative Programming Languages 6 : Haskell Lists Department of Computer Science University of Arizona collberg@gmail.com All functional programming languages have the ConsList
More informationArrays. Arrays (8.1) Arrays. One variable that can store a group of values of the same type. Storing a number of related values.
Arrays Chapter 8 page 471 Arrays (8.1) One variable that can store a group of values of the same type Storing a number of related values o all grades for one student o all temperatures for one month o
More informationExercise 1 ( = 22 points)
1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b
More informationPROGRAMMING IN HASKELL. Chapter 2 - First Steps
PROGRAMMING IN HASKELL Chapter 2 - First Steps 0 The Hugs System Hugs is an implementation of Haskell 98, and is the most widely used Haskell system; The interactive nature of Hugs makes it well suited
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationCSCE 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 informationA First Look at ML. Chapter Five Modern Programming Languages, 2nd ed. 1
A First Look at ML Chapter Five Modern Programming Languages, 2nd ed. 1 ML Meta Language One of the more popular functional languages (which, admittedly, isn t saying much) Edinburgh, 1974, Robin Milner
More informationCSc 372 Comparative Programming Languages. 4 : Haskell Basics
CSc 372 Comparative Programming Languages 4 : Haskell Basics Christian Collberg Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2011 Christian Collberg August 23, 2011
More informationCSc 372 Comparative Programming Languages
CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Christian Collberg collberg+372@gmail.com Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg
More informationCSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona
1/43 CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg Functions over Lists
More informationProgramming Languages 3. Definition and Proof by Induction
Programming Languages 3. Definition and Proof by Induction Shin-Cheng Mu Oct. 22, 2015 Total Functional Programming The next few lectures concerns inductive definitions and proofs of datatypes and programs.
More informationCSE 115. Introduction to Computer Science I
CSE 115 Introduction to Computer Science I Help us help you! When posting to Piazza: tell us what you think the problem is tell us what you've tried tell us where you're getting stuck Just posting a screenshot
More informationLecture 2: List algorithms using recursion and list comprehensions
Lecture 2: List algorithms using recursion and list comprehensions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 12, 2017 Expressions, patterns
More informationINFOB3TC Solutions for Exam 1
Department of Information and Computing Sciences Utrecht University INFOB3TC Solutions for Exam 1 Johan Jeuring Thursday, 19 December 2013, 08:30 10:30 Please keep in mind that there are often many possible
More informationLecture-14 Lookup Functions
Lecture-14 Lookup Functions How do I write a formula to compute tax rates based on income? Given a product ID, how can I look up the product s price? Suppose that a product s price changes over time. I
More informationCSc 372. Comparative Programming Languages. 4 : Haskell Basics. Department of Computer Science University of Arizona
1/40 CSc 372 Comparative Programming Languages 4 : Haskell Basics Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/40 The Hugs Interpreter The
More informationComputer Grade 5. Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May
Computer Grade 5 1 st Term Unit: 1, 2 & 3 Total Periods 38 Lab 10 Months: April and May Summer Vacation: June, July and August 1 st & 2 nd week Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 First term (April) Week
More informationCS 320: Concepts of Programming Languages
CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 08: Type Classes o o Review: What is a type class? Basic Type Classes: Eq, Ord, Enum, Integral,
More informationTREES Lecture 12 CS2110 Spring 2018
TREES Lecture 12 CS2110 Spring 2018 Important Announcements 2 A4 is out now and due two weeks from today. Have fun, and start early! Data Structures 3 There are different ways of storing data, called data
More informationCS 320: Concepts of Programming Languages
CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 06: Useful Haskell Syntax, HO Programming Continued o Goodbye to Bare Bones Haskell: Built-in
More informationIntroduction to Programming, Aug-Dec 2008
Introduction to Programming, Aug-Dec 2008 Lecture 1, Monday 4 Aug 2008 Administrative matters Resource material Textbooks and other resource material for the course: The Craft of Functional Programming
More informationArrays and Pointers (part 2) Be extra careful with pointers!
Arrays and Pointers (part 2) EECS 2031 22 October 2017 1 Be extra careful with pointers! Common errors: l Overruns and underruns Occurs when you reference a memory beyond what you allocated. l Uninitialized
More informationDictionaries. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, KV 5 Jaipur II Shift
Dictionaries Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Introduction Python provides us various options to store multiple values under one variable name.
More informationHaskell: Lists. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, Glenn G.
Haskell: Lists CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
More informationCellular Automata Language (CAL) Language Reference Manual
Cellular Automata Language (CAL) Language Reference Manual Calvin Hu, Nathan Keane, Eugene Kim {ch2880, nak2126, esk2152@columbia.edu Columbia University COMS 4115: Programming Languages and Translators
More informationDo not turn to the next page until the start of the exam.
Introduction to Programming, PIC10A E. Ryu Fall 2017 Midterm Exam Friday, November 3, 2017 50 minutes, 11 questions, 100 points, 8 pages While we don t expect you will need more space than provided, you
More informationB.V. Patel Institute of BMC & IT, UTU 2014
BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we
More informationIntroduction to Haskell
Introduction to Haskell Matt Mullins Texas A&M Computing Society October 6, 2009 Matt Mullins (TACS) Introduction to Haskell October 6, 2009 1 / 39 Outline Introduction to Haskell Functional Programming
More informationCS109A ML Notes for the Week of 1/16/96. Using ML. ML can be used as an interactive language. We. shall use a version running under UNIX, called
CS109A ML Notes for the Week of 1/16/96 Using ML ML can be used as an interactive language. We shall use a version running under UNIX, called SML/NJ or \Standard ML of New Jersey." You can get SML/NJ by
More informationML 4 A Lexer for OCaml s Type System
ML 4 A Lexer for OCaml s Type System CS 421 Fall 2017 Revision 1.0 Assigned October 26, 2017 Due November 2, 2017 Extension November 4, 2017 1 Change Log 1.0 Initial Release. 2 Overview To complete this
More informationProgramming Language Concepts: Lecture 14
Programming Language Concepts: Lecture 14 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 14, 11 March 2009 Function programming
More informationIt is better to have 100 functions operate one one data structure, than 10 functions on 10 data structures. A. Perlis
Chapter 14 Functional Programming Programming Languages 2nd edition Tucker and Noonan It is better to have 100 functions operate one one data structure, than 10 functions on 10 data structures. A. Perlis
More informationGGPerf: A Perfect Hash Function Generator Jiejun KONG June 30, 1997
GGPerf: A Perfect Hash Function Generator Jiejun KONG June 30, 1997 Contents 1 Introduction................................. 1 1.1 Minimal Perfect Hash Function................ 1 1.2 Generators and Scripting....................
More informationCSE 123 Introduction to Computing
CSE 123 Introduction to Computing Lecture 2 Creating Charts with Excel and Working with Formulas and Functions SPRING 2012 Assist. Prof. A. Evren Tugtas Course notes have been prepared using some of the
More informationCS3: Introduction to Symbolic Programming. Lecture 8: Introduction to Higher Order Functions. Spring 2008 Nate Titterton
CS3: Introduction to Symbolic Programming Lecture 8: Introduction to Higher Order Functions Spring 2008 Nate Titterton nate@berkeley.edu Schedule 8 Mar 10-14 Lecture: Higher Order Functions Lab: (Tu/W)
More informationNote that pcall can be implemented using futures. That is, instead of. we can use
Note that pcall can be implemented using futures. That is, instead of (pcall F X Y Z) we can use ((future F) (future X) (future Y) (future Z)) In fact the latter version is actually more parallel execution
More informationRead and fill in this page now
Login: Page - 1 CS3 Midterm 1 Read and fill in this page now Fall 2006 Titterton Name: Instructional Login (eg, cs3-ab): UCWISE login: Lab section (day and time): T.A.: Name of the person sitting to your
More informationCS 320 Midterm Exam. Fall 2018
Name: BU ID: CS 320 Midterm Exam Fall 2018 Write here the number of the problem you are skipping: You must complete 5 of the 6 problems on this exam for full credit. Each problem is of equal weight. Please
More informationCSc Introduction to Computing
CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments
More informationContents. 1. Managing Seed Plan Spreadsheet
By Peter K. Mulwa Contents 1. Managing Seed Plan Spreadsheet Seed Enterprise Management Institute (SEMIs) Managing Seed Plan Spreadsheet Using Microsoft Excel 2010 3 Definition of Terms Spreadsheet: A
More informationExercise 1 ( = 24 points)
1 Exercise 1 (4 + 5 + 4 + 6 + 5 = 24 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a =
More informationIntroduction to Programming: Lecture 6
Introduction to Programming: Lecture 6 K Narayan Kumar Chennai Mathematical Institute http://www.cmi.ac.in/~kumar 28 August 2012 Example: initial segments Write a Haskell function initsegs which returns
More informationTutorial 8 (Array I)
Tutorial 8 (Array I) 1. Indicate true or false for the following statements. a. Every element in an array has the same type. b. The array size is fixed after it is created. c. The array size used to declare
More information"Hello" " This " + "is String " + "concatenation"
Strings About Strings Strings are objects, but there is a special syntax for writing String literals: "Hello" Strings, unlike most other objects, have a defined operation (as opposed to a method): " This
More informationWhy arrays? To group distinct variables of the same type under a single name.
Lesson #7 Arrays Why arrays? To group distinct variables of the same type under a single name. Suppose you need 100 temperatures from 100 different weather stations: A simple (but time consuming) solution
More informationMAP OF OUR REGION. About
About ABOUT THE GEORGIA BULLETIN The Georgia Bulletin is the Catholic newspaper for the Archdiocese of Atlanta. We cover the northern half of the state of Georgia with the majority of our circulation being
More informationCS3 Midterm 1 Fall 2007 Standards and solutions
CS3 Midterm 1 Fall 2007 Standards and solutions Problem 1. And the return value is... ( 9 points) For problems 1-7, write the result of evaluating the Scheme expression that comes before the. If the Scheme
More informationRead and fill in this page now. Your instructional login (e.g., cs3-ab): Your lab section days and time: Name of the person sitting to your left:
CS3 Fall 05 Midterm 1 Read and fill in this page now Your name: Your instructional login (e.g., cs3-ab): Your lab section days and time: Your lab T.A.: Name of the person sitting to your left: Name of
More informationConstructing Triangles Given Sides
Consider Every Side Constructing Triangles Given Sides 3 WARM UP Use the coordinate plane to determine each distance. Show your work. A y C B E D 0 5 5 1. What is the distance from point F to point D?
More information02157 Functional Programming. Michael R. Ha. Lecture 2: Functions, Types and Lists. Michael R. Hansen
Lecture 2: Functions, Types and Lists nsen 1 DTU Compute, Technical University of Denmark Lecture 2: Functions, Types and Lists MRH 13/09/2018 Outline Functions as first-class citizens Types, polymorphism
More informationCSE 115. Introduction to Computer Science I
CSE 115 Introduction to Computer Science I Road map Review Exercises from last time Reading csv files exercise File reading A b i t o f t e x t \n o n s e v e r a l l i n e s \n A text file is a sequence
More informationCS 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 informationIf we have a call. Now consider fastmap, a version of map that uses futures: Now look at the call. That is, instead of
If we have a call (map slow-function long-list where slow-function executes slowly and long-list is a large data structure, we can expect to wait quite a while for computation of the result list to complete.
More informationCSE 3302 Programming Languages Lecture 8: Functional Programming
CSE 3302 Programming Languages Lecture 8: Functional Programming (based on the slides by Tim Sheard) Leonidas Fegaras University of Texas at Arlington CSE 3302 L8 Spring 2011 1 Functional Programming Languages
More informationArrays and Pointers (part 2) Be extra careful with pointers!
Arrays and Pointers (part 2) CSE 2031 Fall 2011 23 October 2011 1 Be extra careful with pointers! Common errors: Overruns and underruns Occurs when you reference a memory beyond what you allocated. Uninitialized
More informationStrings and Arrays. Hendrik Speleers
Hendrik Speleers Overview Characters and strings String manipulation Formatting output Arrays One-dimensional Two-dimensional Container classes List: ArrayList and LinkedList Iterating over a list Characters
More informationOverview. Concepts this lecture String constants Null-terminated array representation String library <strlib.h> String initializers Arrays of strings
CPE 101 slides based on UW course Lecture 19: Strings Overview Concepts this lecture String constants ull-terminated array representation String library String initializers Arrays of strings
More informationTalen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University
Talen en Compilers 2017-2018, period 2 Jurriaan Hage Department of Information and Computing Sciences Utrecht University November 13, 2017 1. Introduction 1-1 This lecture Introduction Course overview
More informationProgramming Logic and Design Sixth Edition
Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions
More informationPROGRAMMING IN HASKELL. Chapter 2 - First Steps
PROGRAMMING IN HASKELL Chapter 2 - First Steps 0 The Hugs System Hugs is an implementation of Haskell 98, and is the most widely used Haskell system; The interactive nature of Hugs makes it well suited
More informationShell 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 informationMAP OF OUR REGION. About
About ABOUT THE GEORGIA BULLETIN The Georgia Bulletin is the Catholic newspaper for the Archdiocese of Atlanta. We cover the northern half of the state of Georgia with the majority of our circulation being
More information(ii) Define a function ulh that takes a list xs, and pairs each element with all other elements in xs.
EXAM FUNCTIONAL PROGRAMMING Tuesday the 1st of October 2016, 08.30 h. - 10.30 h. Name: Student number: Before you begin: Do not forget to write down your name and student number above. If necessary, explain
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationLecture 6,
Lecture 6, 4.16.2009 Today: Review: Basic Set Operation: Recall the basic set operator,!. From this operator come other set quantifiers and operations:!,!,!,! \ Set difference (sometimes denoted, a minus
More informationStrings. Chuan-Ming Liu. Computer Science & Information Engineering National Taipei University of Technology Taiwan
Strings Chuan-Ming Liu Computer Science & Information Engineering National Taipei University of Technology Taiwan 1 Outline String Basic String Library Functions Longer Strings: Concatenation and Whole-Line
More informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
More informationTREES 11/1/18. Prelim Updates. Data Structures. Example Data Structures. Tree Overview. Tree. Singly linked list: Today: trees!
relim Updates Regrades are live until next Thursday @ :9M A few rubric changes are happening Recursion question: -0pts if you continued to print Exception handling write the output of execution of that
More informationBasic types and definitions. Chapter 3 of Thompson
Basic types and definitions Chapter 3 of Thompson Booleans [named after logician George Boole] Boolean values True and False are the result of tests are two numbers equal is one smaller than the other
More informationCHIROPRACTIC MARKETING CENTER
Marketing Plan Sample Marketing Calendar Here is a sample yearly marketing plan. You should use something similar, but of course add or remove strategies as appropriate for your practice. Letter and advertisement
More informationLists. 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 information10/30/2010. Introduction to Control Statements. The if and if-else Statements (cont.) Principal forms: JAVA CONTROL STATEMENTS SELECTION STATEMENTS
JAVA CONTROL STATEMENTS Introduction to Control statements are used in programming languages to cause the flow of control to advance and branch based on changes to the state of a program. In Java, control
More informationShell CSCE 314 TAMU. Haskell Functions
1 CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions can
More informationCSc 110, Spring Lecture 24: print revisited, tuples cont.
CSc 110, Spring 2017 Lecture 24: print revisited, tuples cont. 1 print 2 print revisited We often convert to strings when printing variables: print("the sum is " + str(sum)) This is not always necessary.
More informationExercise 1 ( = 18 points)
1 Exercise 1 (4 + 5 + 4 + 5 = 18 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a = Leaf
More information