CIS 252 Introduction to Computer Science Section M019: Exam 1 (Yellow) February 22, Points Possible
|
|
- Roderick Patrick
- 5 years ago
- Views:
Transcription
1 Name: CIS 252 Introduction to Computer Science Section M019: February 22, 2018 Question Points Possible Points Received Total 100 Instructions: 1. This exam is a closed-book (and closed-notes) exam. 2. Legibility counts! Make sure we can read (and find!) your answers. If you need more room for an answer than that given, use the back side of the pages. Be sure to leave a note indicating where the answer is. 3. This test should have 8 pages (including this cover sheet). Let us know now if your copy does not have the correct number of pages. 4. Unless specified otherwise, you may use any built-in Haskell function you want, as long as you use it correctly (including using its correct name). The last page includes a list of some common Haskell functions and their types.
2 1. (34 points) Suppose that the following definitions are made: import Data.Char ice :: [(Char,Integer)] ice = [( d,12), ( m,3), ( j,5),( f,2)] curl :: [a] -> String curl [] = "skip" curl (x:z) = "vice" curl (w:y:ts) = "lead" sweep :: a -> (Float,a) sweep x = (1.0,x) freeze :: Integer -> [(Char,Integer)] -> String freeze i [] = [] freeze i ((w,p):rest) i == p = w : freeze i rest otherwise = "!!" hurry :: Int -> Bool hurry v = v > 100 even v (a) (22 points) Give the values of the following expressions. (i). 3:5:1:[] (ii). div 14 5 (iii). curl [1,10,100] (iv). hurry 18 (v). [20,24..30] (vi). isupper? (vii). length [[2,4],[7],[],[8,6]] (viii). [ r (r,m) <- ice, odd m] (ix). freeze 12 ice
3 (x). zip [3,6,10,12] [20,30,40] (xi). concat [[2,7],[],[31,8,2]] (b) (12 points) Give the types of the following expressions (e.g., the type of [False] is [Bool]). (i). ["104","days"]:[] (ii). (odd 6, length [3.5]) (iii). unzip ice (iv). sweep Q (v). fst (hurry 13,"sun") (vi). [ sweep b (a,b) <- ice] import Data.Char ice :: [(Char,Integer)] ice = [( d,12), ( m,3), ( j,5),( f,2)] curl :: [a] -> String curl [] = "skip" curl (x:z) = "vice" curl (w:y:ts) = "lead" sweep :: a -> (Float,a) sweep x = (1.0,x) freeze :: Integer -> [(Char,Integer)] -> String freeze i [] = [] freeze i ((w,p):rest) i == p = w : freeze i rest otherwise = "!!" hurry :: Int -> Bool hurry v = v > 100 even v
4 2. (16 points) Consider the following (partial) file system hierarchy, where the numeric labels associated with directories are intended merely as identification for the questions that follow: 1 / 2 dei/ 8 missions/ 9 owca/ 3 doof/ 4 norm/ 10 carl/ 11 mm/ 12 perry/ 13 silentg/ 5 backstory/ 6 inators/ 7 plans/ 14 family/ 15 gear/ 16 missions/ 17 plans/ For each question that follows, suppose that Perry s home directory is directory #12 and that his current working directory is directory #6. (a) If Perry executed the Unix command pwd, what would be the system s response? (b) If Perry executed the Unix command cd.., which directory would become his current working directory? (Give the number of the directory, not the name.) (c) If Perry executed the Unix command cd ~/.., which directory would become his current working directory? (Give the number of the directory, not the name.) (continued on next page)
5 As before, suppose that Perry s home directory is directory #12 and that his current working directory is directory #6. For each of the following tasks, give a single Unix command would allow Perry to complete the task. You should assume that each task is completed independently of the others (i.e., changes made in one task do not affect other tasks). (d) List all files (including hidden files) in directory #7, but do not include info about file permissions and creation dates (e) Create a subdirectory in directory #8 called canada (f) Make a copy of the file watch.pdf (located in directory #10), placing it in directory #15 with the name new.pdf (g) Delete the file vacation (located in directory #17) (h) Move the file seattle (located in directory #16) to directory #13 1 / 2 dei/ 8 missions/ 9 owca/ 3 doof/ 4 norm/ 10 carl/ 11 mm/ 12 perry/ 13 silentg/ 5 backstory/ 6 inators/ 7 plans/ 14 family/ 15 gear/ 16 missions/ 17 plans/
6 3. (16 points) A small burger shop sells burgers and fries (and not much else): The standard cost for a burger is $7, and the cost for an order of fries is $2. To attract new customers, the shop is currently running a promotion: for every two burgers purchased at the standard price, one order of fries is free. The shop also has a loyalty program for repeat customers. Customers who present their membership card at the time of purchase pay only $6 per burger (but they pay full price for all fries). Here are examples of how the pricing works: Ana wishes to purchase five burgers and three orders of fries. She does not present a membership card at the time of purchase. Because she s ordering five burgers, she is eligible for two free orders of fries. She therefore pays a total of $37 (five burgers at $7 apiece, plus $2 for the one non-free order of fries). Blake also wishes to purchase five burgers and three orders of fries, but he does present his membership card at the time of purchase. Because he s using his membership card, he is not eligible for any free orders of fries. He pays a total of $36 (five burgers at $6 apiece, plus three orders of fries at $2 apiece). Cora wishes to purchase three burgers and no fries, and she does not present a membership card at the time of purchase. Because she s ordering three burgers, she would be eligible for one free order of fries, but she doesn t use that benefit. She pays a total of $21 (three burgers at $7 apiece). Your task: Write a Haskell function cost :: Integer -> Integer -> Bool -> Integer such that cost burgs fries card calculates the cost (in dollars) of a customer s food purchase, where burgs indicates the number of burgers purchased, fries indicates the number of orders of fries desired, and card is true precisely when the customer presents a membership card at the time of purchase. If either burgs or fries is negative, the function should return 0. For example, your function should have the following behavior: *Main> cost 5 3 False 37 *Main> cost 5 3 True 36 *Main> cost 3 0 False 21 *Main> cost 3 0 True 18
7 4. (10 points) Write a Haskell function neighbors :: [a] -> [(a,a)] such that neighbors xs returns a list of all pairs of neighboring (i.e., adjacent) elements of xs. For example, the function should have the following behavior: *Main> neighbors [3,0,21,3,3,7,1] [(3,0),(0,21),(21,3),(3,3),(3,7),(7,1)] *Main> neighbors "cis252" [( c, i ),( i, s ),( s, 2 ),( 2, 5 ),( 5, 2 )] *Main> neighbors [3] [] 5. (12 points) Write a Haskell function changefirst :: Char -> String -> String such that changefirst ch cs returns the string obtained by changing the first occurrence of ch in cs to # (everything else in the string stays the same). For example: *Main> changefirst 2 "cis 252" "cis #52" *Main> changefirst A "cis 252" "cis 252"
8 6. (12 points) Write a Haskell function addsome :: Int -> [(Int,Char)] -> Int such that addsome k ps calculates the sum of the first k numbers paired with a lowercase letter in the list ps. (If there are fewer than k pairs with lowercase letters, then the function sums those that exist; when k is nonpositive, the function returns 0.) For example, the list [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] has four numbers paired with lowercase letters: 3, 6, -1, and 6. Thus, addsome has the following behavior: *Main> addsome 1 [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] 3 *Main> addsome 2 [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] 9 *Main> addsome 3 [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] 8 *Main> addsome 10 [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] 14 *Main> addsome (-2) [(5,! ),(3, b ),(6, w ),(8, Q ),(12, $ ),(-1, s ),(6, b )] 0 Types of some standard Haskell functions (:) :: a -> [a] -> [a] (++) :: [a] -> [a] -> [a] (&&), ( ) :: Bool -> Bool -> Bool concat :: [[a]] -> [a] even, odd :: Integral a => a -> Bool length :: [a] -> Int isalpha, isupper, islower :: Char -> Bool toupper, tolower :: Char -> Char fst :: (a,b) -> a snd :: (a,b) -> b zip :: [a] -> [b] -> [(a,b)] unzip :: [(a,b)] -> ([a],[b])
1. (34 points) Suppose that the following definitions are made: (a) (22 points) Give the values of the following expressions.
1. (34 points) Suppose that the following definitions are made: import Data.Char ice :: [(Char,Integer)] ice = [( d,12), ( m,3), ( j,5),( f,2)] curl :: [a] -> String curl [] = "skip" curl (x:z) = "vice"
More informationCIS 252 Introduction to Computer Science Section M013: Exam 1 (Blue) February 22, Points Possible
Name: CIS 252 Introduction to Computer Science Section M013: February 22, 2018 Question Points Possible Points Received 1 34 2 16 3 16 4 10 5 12 6 12 Total 100 Instructions: 1. This exam is a closed-book
More informationCIS 252 Introduction to Computer Science Section M013: Exam 1 (Pink) February 22, Points Possible
Name: CIS 252 Introduction to Computer Science Section M013: February 22, 2018 Question Points Possible Points Received 1 34 2 16 3 16 4 10 5 12 6 12 Total 100 Instructions: 1. This exam is a closed-book
More information1. (34 points) Suppose that the following definitions are made: (a) (22 points) Give the values of the following expressions.
1. (34 points) Suppose that the following definitions are made: import Data.Char field :: [(Char,Integer)] field = [( e,12), ( a,3), ( k,5),( t,2)] huck :: [a] -> Int huck [] = 55 huck (x:z) = 81 huck
More information1. (34 points) Suppose that the following definitions are made: (a) (22 points) Give the values of the following expressions.
1. (34 points) Suppose that the following definitions are made: import Data.Char zone :: [(Int,Char)] zone = [(23, g ), (3, m ), (4, d ), (2, k ), (13, e )] poach :: [a] -> Float poach [] = 6.1 poach (x:z)
More informationCIS 252 Introduction to Computer Science Exam 1 (Green) October 3, Points Possible
Name: CIS 252 Introduction to Computer Science October 3, 2018 Question Points Possible Points Received 1 34 2 16 3 18 4 10 5 10 6 12 Total 100 Instructions: 1. This exam is a closed-book (and closed-notes)
More informationCIS 252 Introduction to Computer Science Section M013: Exam 2 (Green) March 29, Points Possible
Name: CIS 252 Introduction to Computer Science Section M013: March 29, 2018 Question Points Possible Points Received 1 18 2 18 3 12 4 6 5 34 6 12 Total 100 Instructions: 1. This exam is a closed-book (and
More information2. (18 points) Suppose that the following definitions are made (same as in Question 1):
1. (18 points) Suppose that the following definitions are made: import Data.Char data Field = Pasture Char Lawn Integer Float Meadow String [Integer] gaze :: Integer -> Bool gaze m = odd m && m < 10 wonder
More information2. (18 points) Suppose that the following definitions are made (same as in Question 1):
1. (18 points) Suppose that the following definitions are made: import Data.Char data Roadway = Avenue Char Lane [Integer] String Parkway Float Int doze :: Integer -> Bool doze m = even m m > 10 dream
More information2. (18 points) Suppose that the following definitions are made (same as in Question 1):
1. (18 points) Suppose that the following definitions are made: import Data.Char data Avenue = Court Char Road String [Integer] Street Int Float snooze :: Int -> Bool snooze m = even m m < 5 slumber ::
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 informationHaskell Programs. Haskell Fundamentals. What are Types? Some Very Basic Types. Types are very important in Haskell:
Haskell Programs We re covering material from Chapters 1-2 (and maybe 3) of the textbook. Haskell Fundamentals Prof. Susan Older A Haskell program is a series of comments and definitions. Each comment
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 informationCSc 520. Principles of Programming Languages 11: Haskell Basics
CSc 520 Principles of Programming Languages 11: Haskell Basics Christian Collberg Department of Computer Science University of Arizona collberg@cs.arizona.edu Copyright c 2005 Christian Collberg April
More informationCIS 252 Introduction to Computer Science Section M013: Exam 3 (Blue) April 26, Points Possible
Name: CIS 252 Introduction to Computer Science Section M013: April 26, 2018 Question Points Possible Points Received 1 18 2 20 3 12 4 14 5 24 6 12 Total 100 Instructions: 1. This exam is a closed-book
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 informationInformatics 1 Functional Programming Lecture 5. Function properties. Don Sannella University of Edinburgh
Informatics 1 Functional Programming Lecture 5 Function properties Don Sannella University of Edinburgh Part I Booleans and characters Boolean operators not :: Bool -> Bool (&&), ( ) :: Bool -> Bool ->
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 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 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 informationInformatics 1 Functional Programming 19 Tuesday 23 November IO and Monads. Philip Wadler University of Edinburgh
Informatics 1 Functional Programming 19 Tuesday 23 November 2010 IO and Monads Philip Wadler University of Edinburgh The 2010 Informatics 1 Competition Sponsored by Galois (galois.com) List everyone who
More informationFunctional Programming and Haskell
Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming
More informationEDAF40. 2nd June :00-19:00. WRITE ONLY ON ONE SIDE OF THE PAPER - the exams will be scanned in and only the front/ odd pages will be read.
EDAF40 2nd June 2017 14:00-19:00 WRITE ONLY ON ONE SIDE OF THE PAPER - the exams will be scanned in and only the front/ odd pages will be read. DO NOT WRITE WITH OTHER COLOUR THAN BLACK - coloured text
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 informationInformatics 1 Functional Programming Lectures 15 and 16. IO and Monads. Don Sannella University of Edinburgh
Informatics 1 Functional Programming Lectures 15 and 16 IO and Monads Don Sannella University of Edinburgh Part I The Mind-Body Problem The Mind-Body Problem Part II Commands Print a character putchar
More informationWrite code that simulates one roll of a 6-sided die and prints out the
CS 101, Spring 2017 Mar 14th Exam 2 Name: Question 1. [5 points] If i = 4 and j = 2, what will print: true or false? Briefly explain. if ((i!= 3) (j < 2)) { printf("true"); else { printf("false"); Question
More informationConverting a Lowercase Letter Character to Uppercase (Or Vice Versa)
Looping Forward Through the Characters of a C String A lot of C string algorithms require looping forward through all of the characters of the string. We can use a for loop to do that. The first character
More informationA tour of the Haskell Prelude
A tour of the Haskell Prelude Bernie Pope 2001 1 Haskell The Haskell language was conceived during a meeting held at the 1987 Functional Programming and Computer Architecture conference (FPCA 87). At the
More informationCS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam
Seat Number Name CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam This is a closed book exam. Answer all of the questions on the question paper in the space provided. If
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 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 informationFunctional Programming TDA 452, DIT 142
Chalmers Göteborgs Universitet 2018-01-11 Examiner: Thomas Hallgren, D&IT, Answering questions at approx 15.00 (or by phone) Functional Programming TDA 452, DIT 142 2018-01-11 14.00 18.00 Samhällsbyggnad
More informationHaskell An Introduction
Haskell An Introduction What is Haskell? General purpose Purely functional No function can have side-effects IO is done using special types Lazy Strongly typed Polymorphic types Concise and elegant A First
More informationHaskell Modules. Input and Output. Urtė Zubkaitė
Haskell Modules. Input and Output Urtė Zubkaitė Modules in Haskell A Haskell program is a collection of modules where the main module loads up the other modules and then uses the functions defined in them
More informationHaskell Overview II (2A) Young Won Lim 9/26/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationThe Caesar Cipher Informatics 1 Functional Programming: Tutorial 3
The Caesar Cipher Informatics 1 Functional Programming: Tutorial 3 Heijltjes, Wadler Due: The tutorial of week 5 (23/24 Oct.) Reading assignment: Chapters 8 and 9 (pp. 135-166) Please attempt the entire
More informationA general introduction to Functional Programming using Haskell
A general introduction to Functional Programming using Haskell Matteo Rossi Dipartimento di Elettronica e Informazione Politecnico di Milano rossi@elet.polimi.it 1 Functional programming in a nutshell
More informationOverview. Declarative Languages D7012E. Overloading. Overloading Polymorphism Subtyping
Overview Declarative Languages D7012E Lecture 4: The Haskell type system Fredrik Bengtsson / Johan Nordlander Overloading & polymorphism Type classes instances of type classes derived type classes Type
More informationChapter 10 Characters, Strings, and the string class
Standard Version of Starting Out with C++, 4th Edition Chapter 10 Characters, Strings, and the string class Copyright 2003 Scott/Jones Publishing Topics 10.1 Character Testing 10.2 Character Case Conversion
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationCOMPUTER SCIENCE (083)
Roll No. Code : 112011-083-A Please check that this question paper contains 7 questions and 6 printed pages. CLASS-XI COMPUTER SCIENCE (083) Time Allowed : 3 Hrs. Maximum Marks : 70 General Instructions
More informationCSCE 314 Programming Languages. Monadic Parsing
CSCE 314 Programming Languages Monadic Parsing Dr. Hyunyoung Lee 1 What is a Parser? A parser is a program that takes a string of characters (or a set of tokens) as input and determines its syntactic structure.
More informationCase by Case. Chapter 3
Chapter 3 Case by Case In the previous chapter, we used the conditional expression if... then... else to define functions whose results depend on their arguments. For some of them we had to nest the conditional
More informationFunctional Programming for Logicians - Lecture 1
Functional Programming for Logicians - Lecture 1 Functions, Lists, Types Malvin Gattinger 4 June 2018 module L1 where Introduction Who is who Course website: https://malv.in/2018/funcproglog/ Malvin Gattinger
More informationSELECTION. (Chapter 2)
SELECTION (Chapter 2) Selection Very often you will want your programs to make choices among different groups of instructions For example, a program processing requests for airline tickets could have the
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch
More informationHaskell Types COMP360
Haskell Types COMP360 No computer has ever been designed that is ever aware of what it's doing; but most of the time, we aren't either. Marvin Minsky Haskell Programming Assignment A Haskell programming
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 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 information1 The smallest free number
1 The smallest free number Introduction Consider the problem of computing the smallest natural number not in a given finite set X of natural numbers. The problem is a simplification of a common programming
More informationCSCE 314 Programming Languages. Functional Parsers
CSCE 314 Programming Languages Functional Parsers Dr. Hyunyoung Lee 1 What is a Parser? A parser is a program that takes a text (set of tokens) and determines its syntactic structure. String or [Token]
More informationFunctional Programming TDA 452, DIT 142
Chalmers Göteborgs Universitet 2016-04-07 Examiner: David Sands dave@chalmers.se. Answering questions on the day of the exam (at approx 15.00): Gregoire Detrez (tel: 073 55 69 550) and at other times by
More informationCSCE 314 Programming Languages. Monadic Parsing
CSCE 314 Programming Languages Monadic Parsing Dr. Hyunyoung Lee 1 What is a Parser? A parser is a program that takes a string of characters (or a set of tokens) as input and determines its syntactic structure.
More informationChapter 10: Characters, C- Strings, and More About the string Class
Chapter 10: Characters, C- Strings, and More About the string Class 10.1 Character Testing Character Testing require cctype header file FUNCTION isalpha isalnum isdigit islower isprint ispunct isupper
More informationChapter 10: Character Testing. From Program Character Case Conversion 8/23/2014. Character Testing. Character Case Conversion
Chapter 10: Characters, C- Strings, and More About the string Class 10.1 Character Testing Character Testing Requires cctype header file From Program 10-1 FUNCTION isalpha isalnum isdigit islower isprint
More informationSplit up Syllabus (Session )
Split up Syllabus (Session- -17) COMPUTER SCIENCE (083) CLASS XI Unit No. Unit Name Marks 1 COMPUTER FUNDAMENTALS 10 2 PROGRAMMING METHODOLOGY 12 3 INTRODUCTION TO C++ 14 4 PROGRAMMING IN C++ 34 Total
More informationITEC2620 Introduction to Data Structures
ITEC2620 Introduction to Data Structures Lecture 10a Grammars II Review Three main problems Derive a sentence from a grammar Develop a grammar for a language Given a grammar, determine if an input is valid
More informationCMSC 330, Fall 2018 Midterm 1
CMSC 330, Fall 2018 Midterm 1 Name Teaching Assistant Kameron Aaron Danny Chris Michael P. Justin Cameron B. Derek Kyle Hasan Shriraj Cameron M. Alex Michael S. Pei-Jo Instructions Do not start this exam
More informationProgramming Languages ML Programming Project Due 9/28/2001, 5:00 p.m.
Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m. Functional Suite Instead of writing a single ML program, you are going to write a suite of ML functions to complete various tasks.
More informationCSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:
CSE 131 Introduction to Computer Science Fall 2016 Given: 29 September 2016 Exam I Due: End of Exam Session This exam is closed-book, closed-notes, no electronic devices allowed The exception is the "sage
More informationStudy Guide for Test 2
Study Guide for Test 2 Topics: decisions, loops, arrays, c-strings, linux Material Selected from: Chapters 4, 5, 6, 7, 10.1, 10.2, 10.3, 10.4 Examples 14 33 Assignments 4 8 Any syntax errors are unintentional
More information3. Functions. Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.
1 3. Functions 1. What are the merits and demerits of modular programming? Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.
More informationTopic 5: Higher Order Functions
Topic 5: Higher Order Functions 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10,
More informationTopic 5: Higher Order Functions
Topic 5: Higher Order Functions 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10,
More informationcs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).
cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion
More informationLearning Recursion. Recursion [ Why is it important?] ~7 easy marks in Exam Paper. Step 1. Understand Code. Step 2. Understand Execution
Recursion [ Why is it important?] ~7 easy marks in Exam Paper Seemingly Different Coding Approach In Fact: Strengthen Top-down Thinking Get Mature in - Setting parameters - Function calls - return + work
More informationModule Title: Informatics 1 Functional Programming (first sitting) Exam Diet (Dec/April/Aug): December 2014 Brief notes on answers:
Module Title: Informatics 1 Functional Programming (first sitting) Exam Diet (Dec/April/Aug): December 2014 Brief notes on answers: -- Full credit is given for fully correct answers. -- Partial credit
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 informationFundamentals of Computer Programming Using C
CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US01CBCA01 (Fundamentals of Computer Programming Using C) *UNIT 3 (Structured Programming, Library Functions
More informationDHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++
DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language
More informationControl Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping
Control Structures A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Conditional Execution if is a reserved word The most basic syntax for
More informationChapter 10: Characters, C- Strings, and More About the string Class Character Testing
Chapter 10: Characters, C- Strings, and More About the string Class 1 10.1 Character Testing 2 Character Testing require cctype header file FUNCTION isalpha isalnum isdigit islower isprint ispunct isupper
More informationSAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1
FACULTY OF SCIENCE AND TECHNOLOGY SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1 ACADEMIC SESSION 2014; SEMESTER 3 PRG102D: BASIC PROGRAMMING CONCEPTS Section A Compulsory section Question
More informationSystem Design and Programming II
System Design and Programming II CSCI 194 Section 01 CRN: 10968 Fall 2017 David L. Sylvester, Sr., Assistant Professor Chapter 10 Characters, Strings, and the string Class Character Testing The C++ library
More informationCDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)
CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014) Name: USF ID: Problem Points Score 1 10 2 10 3 15 4 15 5 10 6 20 otal 80 Exam Rules Use the back of the exam paper as necessary. But indicate clearly
More informationProgramming in Haskell Aug-Nov 2015
Programming in Haskell Aug-Nov 2015 LECTURE 5 AUGUST 18, 2015 S P SURESH CHENNAI MATHEMATICAL INSTITUTE The datatype Char Values are written with single quotes a, 3, %, #, Character symbols stored in a
More informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2004 What is your name?: (0 points) There are two sections: I. True/False..............52 points; ( 26 questions, 2 points each) II.
More informationExam 1 Practice CSE 232 Summer 2018 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.
Name: Section: INSTRUCTIONS: (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN. (2) The total for the exam is 100 points (3) There are 8 pages with 32 problem; 15 multiple-choice, 15
More informationcommandname flags arguments
Unix Review, additional Unix commands CS101, Mock Introduction This handout/lecture reviews some basic UNIX commands that you should know how to use. A more detailed description of this and other commands
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 informationCS 440: Programming Languages and Translators, Spring 2019 Mon
Haskell, Part 4 CS 440: Programming Languages and Translators, Spring 2019 Mon 2019-01-28 More Haskell Review definition by cases Chapter 6: Higher-order functions Revisit currying map, filter Unnamed
More informationFunctional Programming Mid-term exam Tuesday 3/10/2017
Functional Programming Mid-term exam Tuesday 3/10/2017 Name: Student number: Before you begin: Do not forget to write down your name and student number above. If necessary, explain your answers in English.
More informationIntroduction to Programming and 4Algorithms Abstract Types. Uwe R. Zimmer - The Australian National University
Introduction to Programming and 4Algorithms 2015 Uwe R. Zimmer - The Australian National University [ Thompson2011 ] Thompson, Simon Haskell - The craft of functional programming Addison Wesley, third
More informationSolving Equations Involving Integers
12 MODULE 2. FUNDAMENTALS OF ALGEBRA 2c Solving Equations Solving Equations Involving Integers We now review solving equations involving integers. These equations require the use of the distributive property
More informationHaskell Overview II (2A) Young Won Lim 8/23/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationName CIS 201 Midterm II: Chapters 1-8
Name CIS 201 Midterm II: Chapters 1-8 December 15, 2010 Directions: This is a closed book, closed notes midterm. Place your answers in the space provided. The point value for each question is indicated.
More informationList Processing in Ocaml
CS251 Programming Languages Handout # 14 Prof. Lyn Turbak February 2, 2007 Wellesley College List Processing in Ocaml Given a list of integers ns, suppose we want to return a new list of the same length
More informationMain Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University
C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types
More informationCS 101, Spring 2014 April 1st Exam 2 Question 1. [3 points] What output is printed by the following code?
CS 101, Spring 2014 April 1st Exam 2 Name: Question 1. [3 points] What output is printed by the following code? int arr[4] = {13, 1, 9, 18; printf("%i\n", arr[3]); Question 2. [3 points] Specify a function
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 informationGHCi: Getting started (1A) Young Won Lim 5/26/17
GHCi: Getting started (1A) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
More informationSolution sheet 1. Introduction. Exercise 1 - Types of values. Exercise 2 - Constructors
Solution sheet 1 Introduction Please note that there can be other solutions than those listed in this document. This is a literate Haskell file which is available as PDF, as well as literate Haskell source
More informationComputer Science II CSci 1200 Test 2 Overview and Practice
Computer Science II CSci 1200 Test 2 Overview and Practice Overview Test 2 will be held Friday, March 21, 2008 2:00-3:45pm, Darrin 308. No make-ups will be given except for emergency situations, and even
More informationWatch out for the arrows. Recollecting Haskell, Part V. A start on higher types: Mapping, 1. A start on higher types: Mapping, 2.
Watch out for the arrows Recollecting Haskell, Part V Higher Types CIS 352/Spring 2018 Programming Languages January 30, 2018 1 / 28 2 / 28 A start on higher types: Mapping, 1 Mapping via list comprehension
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationHaskell Overview II (2A) Young Won Lim 8/9/16
(2A) Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationReviewing all Topics this term
Today in CS161 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for) Functions (pass by value, pass by reference) Arrays (specifically arrays of characters)
More informationQuestion 2. [2 points] Which of the following is a correct statement to obtain user input? (Assume that fleems is an int variable.
CS 101, Spring 2016 Feb 23rd Exam 1 Name: Question 1. [2 points] Write a statement(s) to declare a variable named num students that will be used to store the number of students and set the value of the
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More information