MTAT Agile Software Development in the Cloud Lecture 4: More on Ruby
|
|
- Kory Marshall
- 6 years ago
- Views:
Transcription
1 MTAT Agile Software Development in the Cloud Lecture 4: More on Ruby Luciano García-Bañuelos University of Tartu
2 Regular Expressions Widely use tool for specifying (and implemen5ng) pa7ern matching processors and even lexical analyzers RegExp are first- class ci5zens in Ruby expr1 = Regexp.new('\(\d+\)') expr2 = /\(\d+\)/ Ruby s syntax is mostly borrowed from Perl s
3 A toy example =~ nil (cf. false) when no match index of the first occur. on the string, otherwise match nil when no match Instance of MatchData, otherwise def code_matcher(expr, str) if expr =~ str puts "Country code #{expr.match(str)} else puts 'No country code provided end end phone1 = '(372) ' phone2 = ' ' expr = /\(\d+\)/ code_matcher(expr, phone1) code_matcher(expr, phone2)
4 Character classes Example /[Rr]uby/ /Rub(y en)/ /[aeiou]/ /[0-9]/ /[a- za- Z]/ /[^aeiou]/ /[^0-9]/ Descrip2on Matches Ruby or ruby Matches Ruby or Ruben Matches a single lowercase vowel Matches a single digit Matches a single alphabe5c character Matches anything other than a lowercase vowel Matches anything other than a digit
5 Character classes (continuation) Abrevia2on Descrip2on \d A digit character, as [0-9] \D Any character except a digit, as [^0-9] \s Any whitespace, as [ \t\r\n\f] \S Any character except a whitespace \w Any word character, as [a- za- Z0-9_] \W Any character except a work character, as [^a- za- Z0-9_]. Any character except a whitespace POSIX character classes [:alpha:], [:alnum:], [:blank:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], [:xdigit:]
6 Repetition and anchoring Example /ruby?/ /ruby*/ /ruby+/ /\d{3}/ /\d{3,}/ /\d{3,5}/ Descrip2on Matches rub or ruby Matches rub followed by 0 or more y s Matches rub followed by 1 or more y s Matches exactly three digits Matches 3 o more digits Matches 3, 4 or 5 digits Example /^Ruby/ /Ruby$/ /\ARuby/ /Ruby\Z/ /\bruby\b/ Descrip2on Matches rub or ruby Matches rub followed by 0 or more y s Matches rub followed by 1 or more y s Matches exactly three digits Matches Ruby if and only if found as single word
7 Matching groups exp1 = /(\d+)\d+(\d+)/ exp2 = /\d+/ m = exp1.match("_ 123 abc 345 x 67 end") puts "#{$1}, #{$2} m.captures exp2.match("_ 123 abc 345 x 67 end") puts "#{$1}, #{$2}" m = "_ 123 abc 345 x 67 end".scan(/(\d+)/) m.each { x puts x }
8 Matching and replacing str1 = "he said 'hello' to me" str2 = str1.dup puts str1.gsub(/he/,'he') puts str2.gsub(/\bhe\b/,'he')
9 Blocks class Array def iterate self.each_with_index do n, i self[i] = yield(n) end end end array = [1, 2, 3, 4] array.iterate do n n ** 2 end puts array.inspect
10 Blocks => Procs class Array def iterate(&code) self.each_with_index do n, i self[i] = code.call(n) end end end array = [1, 2, 3, 4] array.iterate do n n ** 2 end puts array.inspect
11 Procs can be reused class Array def iterate(code) self.each_with_index do n, i self[i] = code.call(n) end end end array_1 = [1, 2, 3, 4] array_2 = [2, 3, 4, 5] square = Proc.new { n n ** 2} array_1.iterate(square) array_2.iterate(square) puts array_1.inspect puts array_2.inspect
12 Lambdas class Array def iterate(code) self.each_with_index do n, i self[i] = code.call(n) end end end array = [1, 2, 3, 4] array.iterate( lambda { n n ** 2 }) puts array.inspect
13 Lambdas strictly check number of parameters def args(code) one, two = 1, 2 code.call(one, two) end args(proc.new{ a, b, c puts "Give me a #{a} and a #{b} and a #{c.class}"}) args(lambda{ a, b, c puts "Give me a #{a} and a #{b} and a #{c.class}"})
14 Lambdas perform diminutive returns def proc_return Proc.new { return "Proc.new"}.call return "proc_return method finished" end def lambda_return lambda { return "lambda" }.call return "lambda_return method finished" end puts proc_return puts lambda_return
15 Classes and Mixins module Persistence def load sfilename puts Reading #{sfilename} contents into 'my_data'" end def save sfilename puts "Persisting into '#{sfilename}'" end end class MyClass include Persistence attr :my_data def = somedata end end b = MyClass.new b.data = "This_15_my_pwd" b.save("passwords") b.load("passwords")
16 Finally metaprogramming class Polyglot = {estonian: "Tere hommikust", english: "Good morning"} def Polyglot.add_language(language, greeting) = greeting if language.is_a? Symbol end def method_missing(name) unless puts else super end end end a = Polyglot.new a.estonian a.english
MTAT Agile Software Development in the Cloud. Lecture 3: Ruby (cont.)
MTAT.03.295 Agile Software Development in the Cloud Lecture 3: Ruby (cont.) Luciano García-Bañuelos University of Tartu Let s play with our example tree1 = BinaryTree.new(10) tree1.insert(5) tree1.insert(15)
More informationNo variable declara<ons. sum = 0! i = 1! while i <= 10 do! sum += i*i! i = i + 1! end! print "Sum of squares is #{sum}\n"!
Basic syntax No variable declara
More informationRuby Regular Expressions AND FINITE AUTOMATA
Ruby Regular Expressions AND FINITE AUTOMATA Why Learn Regular Expressions? RegEx are part of many programmer s tools vi, grep, PHP, Perl They provide powerful search (via pattern matching) capabilities
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 7, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater Regular Expression A new level of mastery over your data. Pattern matching
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationCSE 413 Programming Languages & Implementation. Hal Perkins Winter 2019 Ruby Containers, Blocks, and Procs
CSE 413 Programming Languages & Implementation Hal Perkins Winter 2019 Ruby Containers, Blocks, and Procs CSE413 Winter 2019 1 The Plan Ruby container data structures Blocks and control structures (iterators,
More informationRegular Expressions. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 9
Regular Expressions Computer Science and Engineering College of Engineering The Ohio State University Lecture 9 Language Definition: a set of strings Examples Activity: For each above, find (the cardinality
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationComputing Unit 3: Data Types
Computing Unit 3: Data Types Kurt Hornik September 26, 2018 Character vectors String constants: enclosed in "... " (double quotes), alternatively single quotes. Slide 2 Character vectors String constants:
More informationLearning Ruby. Regular Expressions. Get at practice page by logging on to csilm.usu.edu and selecting. PROGRAMMING LANGUAGES Regular Expressions
Learning Ruby Regular Expressions Get at practice page by logging on to csilm.usu.edu and selecting PROGRAMMING LANGUAGES Regular Expressions Regular Expressions A regular expression is a special sequence
More informationLecture 3. Miscellaneous Ruby and Testing
Lecture 3 Miscellaneous Ruby and Testing 1 Sublime Text Guide I wrote a quick Sublime Text Guide that will help with Rubocop offenses It ll walk you through: Using spaces instead of tabs by default Using
More informationIndian Institute of Technology Kharagpur. PERL Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.
Indian Institute of Technology Kharagpur PERL Part III Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 23: PERL Part III On completion, the student will be able
More informationCSE 413 Final Exam. June 7, 2011
CSE 413 Final Exam June 7, 2011 Name The exam is closed book, except that you may have a single page of hand-written notes for reference plus the page of notes you had for the midterm (although you are
More informationMore Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1
More Scripting and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 Regular Expression Summary Regular Expression Examples Shell Scripting 2 Do not confuse filename globbing
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationPaolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems
aim to facilitate the solution of text manipulation problems are symbolic notations used to identify patterns in text; are supported by many command line tools; are supported by most programming languages;
More informationCSE 413 Final Exam Spring 2011 Sample Solution. Strings of alternating 0 s and 1 s that begin and end with the same character, either 0 or 1.
Question 1. (10 points) Regular expressions I. Describe the set of strings generated by each of the following regular expressions. For full credit, give a description of the sets like all sets of strings
More informationCS160A EXERCISES-FILTERS2 Boyd
Exercises-Filters2 In this exercise we will practice with the Unix filters cut, and tr. We will also practice using paste, even though, strictly speaking, it is not a filter. In addition, we will expand
More informationWriting a Lexer. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, February 6, Glenn G.
Writing a Lexer CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, February 6, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
More informationChapter 1. Fundamentals of Higher Order Programming
Chapter 1 Fundamentals of Higher Order Programming 1 The Elements of Programming Any powerful language features: so does Scheme primitive data procedures combinations abstraction We will see that Scheme
More informationLexical Analysis. Lecture 3-4
Lexical Analysis Lecture 3-4 Notes by G. Necula, with additions by P. Hilfinger Prof. Hilfinger CS 164 Lecture 3-4 1 Administrivia I suggest you start looking at Python (see link on class home page). Please
More informationConfiguring the RADIUS Listener LEG
CHAPTER 16 Revised: July 28, 2009, Introduction This module describes the configuration procedure for the RADIUS Listener LEG. The RADIUS Listener LEG is configured using the SM configuration file p3sm.cfg,
More informationRegex, Sed, Awk. Arindam Fadikar. December 12, 2017
Regex, Sed, Awk Arindam Fadikar December 12, 2017 Why Regex Lots of text data. twitter data (social network data) government records web scrapping many more... Regex Regular Expressions or regex or regexp
More informationRegular Expressions. Todd Kelley CST8207 Todd Kelley 1
Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 POSIX character classes Some Regular Expression gotchas Regular Expression Resources Assignment 3 on Regular Expressions
More informationLecture 27. Lecture 27: Regular Expressions and Python Identifiers
Lecture 27 Lecture 27: Regular Expressions and Python Identifiers Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names
More informationOne can evaluate any valid string as code at run time using eval.
Metaprogramming Metaprogramming means writing code that writes code. This allows us to modify the behavior of a program at run time. Ruby has several metaprogramming facilities. One can add create a new
More informationUnderstanding Regular Expressions, Special Characters, and Patterns
APPENDIXA Understanding Regular Expressions, Special Characters, and Patterns This appendix describes the regular expressions, special or wildcard characters, and patterns that can be used with filters
More informationCSE au Final Exam Sample Solution
CSE 413 12au Final Exam Sample Solution Question 1. (10 points) Regular expressions I. Describe the set of strings generated by each of the following regular expressions. For full credit, give a description
More informationProgramming Paradigms
PP 2016/17 Unit 4 Ruby Advanced 1/42 Programming Paradigms Unit 4 Ruby Advanced J. Gamper Free University of Bozen-Bolzano Faculty of Computer Science IDSE PP 2016/17 Unit 4 Ruby Advanced 2/42 Outline
More informationCS 5142 Scripting Languages
CS 5142 Scripting Languages 10/25/2012 Ruby 1 Outline Ruby Martin Hirzel 2 About Ruby Invented 1995 by Yokihiro Matz Matsumoto Influenced by SmallTalk Everything is an object (even e.g., integers) Blocks
More information正则表达式 Frank from https://regex101.com/
符号 英文说明 中文说明 \n Matches a newline character 新行 \r Matches a carriage return character 回车 \t Matches a tab character Tab 键 \0 Matches a null character Matches either an a, b or c character [abc] [^abc]
More informationIntroduction to String Manipulation
Introduction to Computer Programming Introduction to String Manipulation CSCI-UA.0002 What is a String? A String is a data type in the Python programming language A String can be described as a "sequence
More informationA Brief Introduction to Scheme (I)
A Brief Introduction to Scheme (I) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Scheme Scheme I p.1/44 Scheme: Feature Set A
More informationCS Unix Tools. Fall 2010 Lecture 5. Hussam Abu-Libdeh based on slides by David Slater. September 17, 2010
Fall 2010 Lecture 5 Hussam Abu-Libdeh based on slides by David Slater September 17, 2010 Reasons to use Unix Reason #42 to use Unix: Wizardry Mastery of Unix makes you a wizard need proof? here is the
More informationCMSC 330: Organization of Programming Languages
: Organization of Programming Languages Ruby Regular Expressions 1 Last Lecture Ruby language Implicit variable declarations Dynamic typing Many control statements Classes & objects Strings 2 Introduction
More informationCMSC 330: Organization of Programming Languages. Ruby Regular Expressions
CMSC 330: Organization of Programming Languages Ruby Regular Expressions 1 String Processing in Ruby Earlier, we motivated scripting languages using a popular application of them: string processing The
More informationDescribing Languages with Regular Expressions
University of Oslo : Department of Informatics Describing Languages with Regular Expressions Jonathon Read 25 September 2012 INF4820: Algorithms for AI and NLP Outlook How can we write programs that handle
More informationPieter van den Hombergh. April 13, 2018
Intro ergh Fontys Hogeschool voor Techniek en Logistiek April 13, 2018 ergh/fhtenl April 13, 2018 1/11 Regex? are a very power, but also complex tool. There is the saying that: Intro If you start with
More informationCMSC 330: Organization of Programming Languages. Ruby Regular Expressions
CMSC 330: Organization of Programming Languages Ruby Regular Expressions 1 String Processing in Ruby Earlier, we motivated scripting languages using a popular application of them: string processing The
More informationCS 211 Regular Expressions
CS 211 Regular Expressions 2-1 REGULAR EXPRESSIONS 2 Processing Input If we know how to read in a line of input, what else might we want to do with it? Analyze it in some way, based on some pattern Extract
More informationConfiguring the RADIUS Listener Login Event Generator
CHAPTER 19 Configuring the RADIUS Listener Login Event Generator Published: December 21, 2012 Introduction This chapter describes the configuration procedure for the RADIUS listener Login Event Generator
More informationCSE 401 Midterm Exam Sample Solution 2/11/15
Question 1. (10 points) Regular expression warmup. For regular expression questions, you must restrict yourself to the basic regular expression operations covered in class and on homework assignments:
More informationUNIX / LINUX - REGULAR EXPRESSIONS WITH SED
UNIX / LINUX - REGULAR EXPRESSIONS WITH SED http://www.tutorialspoint.com/unix/unix-regular-expressions.htm Copyright tutorialspoint.com Advertisements In this chapter, we will discuss in detail about
More informationControl flow statements
Control flow statements It is important to make decisions in programming about how your code will be looked at. You may need to be selective, iterative or repetitive with the code statements. Python provides
More informationRegular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland
Regular Expressions Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland November 11 th, 2015 Regular expressions provide a flexible way
More informationIntroduction to Ruby. SWEN-250 Personal Software Engineering
Introduction to Ruby SWEN-250 Personal Software Engineering A Bit of History Yukihiro "Matz'' Matsumoto Created a language he liked to work in. Been around since mid-90s. Caught on in early to mid 00s.
More informationRuby : A Dynamic Object Oriented Scripting Language
Ruby : A Dynamic Object Oriented Scripting Language Kuldeep Gharat kuldeep@cse.iitb.ac.in November 29, 2004 Kuldeep Gharat kuldeep@cse.iitb.ac.in () Ruby : A Dynamic Object Oriented Scripting Language
More informationServer-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub 2 Regular expressions
More informationRegular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)
Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in
More informationGetting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013
CSE 231, Rich Enbody Office Hours After class By appointment send an email 2 1 Project 1 Python arithmetic Do with pencil, paper and calculator first Idle Handin Help room 3 What is a Computer Program?
More informationSTREAM EDITOR - REGULAR EXPRESSIONS
STREAM EDITOR - REGULAR EXPRESSIONS http://www.tutorialspoint.com/sed/sed_regular_expressions.htm Copyright tutorialspoint.com It is the regular expressions that make SED powerful and efficient. A number
More informationSummer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define
CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationSCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017
SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationBashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009
Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment
More informationPattern Matching. An Introduction to File Globs and Regular Expressions
Pattern Matching An Introduction to File Globs and Regular Expressions Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your disadvantage, there are two different forms of patterns
More informationRegular Expressions. Regular Expression Syntax in Python. Achtung!
1 Regular Expressions Lab Objective: Cleaning and formatting data are fundamental problems in data science. Regular expressions are an important tool for working with text carefully and eciently, and are
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationSCHEME AND CALCULATOR 5b
SCHEME AND CALCULATOR 5b COMPUTER SCIENCE 6A July 25, 203 In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationPIC 16: Iterators and Generators
PIC 16: Iterators and Generators Assigned 10/9/2018. To be completed before lecture 10/12/2018. Intended Learning Outcomes. By the end of this preparatory assignment, students should be able to: implement
More informationPattern Matching. An Introduction to File Globs and Regular Expressions. Adapted from Practical Unix and Programming Hunter College
Pattern Matching An Introduction to File Globs and Regular Expressions Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More informationMUTABLE LISTS AND DICTIONARIES 4
MUTABLE LISTS AND DICTIONARIES 4 COMPUTER SCIENCE 61A Sept. 24, 2012 1 Lists Lists are similar to tuples: the order of the data matters, their indices start at 0. The big difference is that lists are mutable
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationScheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.
Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu
More informationMTAT Agile Software Development
MTAT.03.295 Agile Software Development Lecture 1: Introduction Luciano García-Bañuelos Course objective The objective of this course is to introduce some of the practices on agile software development,
More informationCSE341 Autumn 2017, Final Examination December 12, 2017
CSE341 Autumn 2017, Final Examination December 12, 2017 Please do not turn the page until 2:30. Rules: The exam is closed-book, closed-note, etc. except for both sides of one 8.5x11in piece of paper. Please
More informationOutline CS4120/4121. Compilation in a Nutshell 1. Administration. Introduction to Compilers Andrew Myers. HW1 out later today due next Monday.
CS4120/4121 Introduction to Compilers Andrew Myers Lecture 2: Lexical Analysis 31 August 2009 Outline Administration Compilation in a nutshell (or two) What is lexical analysis? Writing a lexer Specifying
More informationRegex Guide. Complete Revolution In programming For Text Detection
Regex Guide Complete Revolution In programming For Text Detection What is Regular Expression In computing, a regular expressionis a specific pattern that provides concise and flexible means to "match"
More informationCSE341 Spring 2017, Final Examination June 8, 2017
CSE341 Spring 2017, Final Examination June 8, 2017 Please do not turn the page until 8:30. Rules: The exam is closed-book, closed-note, etc. except for both sides of one 8.5x11in piece of paper. Please
More informationCSC 121: Computer Science for Statistics
CSC 121: Computer Science for Statistics Radford M. Neal, University of Toronto, 2017 http://www.cs.utoronto.ca/ radford/csc121/ Week 3 Making Functions Do Different Things, Using if When you call a function
More informationCMSC330 Fall 2014 Midterm 1 Grading
CMSC330 Fall 2014 Midterm 1 Grading 1. (8 pts) Programming languages (PL) et al. For the following multiple choice questions, circle the letter(s) on the right corresponding to the best answer(s) to each
More informationClasses and Objects in Ruby
Computer Science and Engineering IIT Bombay kuhoo@cse.iitb.ac.in Nov 29, 2004 Classes and Objects Rubby Object A set of flags, instance variables and an associated class Rubby Class An object of class
More informationSyntactic Analysis. CS345H: Programming Languages. Lecture 3: Lexical Analysis. Outline. Lexical Analysis. What is a Token? Tokens
Syntactic Analysis CS45H: Programming Languages Lecture : Lexical Analysis Thomas Dillig Main Question: How to give structure to strings Analogy: Understanding an English sentence First, we separate a
More informationLecture 3. Miscellaneous Ruby and Testing 1 / 40
Lecture 3 Miscellaneous Ruby and Testing 1 / 40 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any
More informationfile:///users/dave/tmp/rubyadv/html/metaprogramming.html
Page 1 of 13 Metaprogramming Object state behavior Me, Me, Me First, understand self self self is the current object Default receiver for method calls with no receiver Place where instance variables are
More informationYOLOP Language Reference Manual
YOLOP Language Reference Manual Sasha McIntosh, Jonathan Liu & Lisa Li sam2270, jl3516 and ll2768 1. Introduction YOLOP (Your Octothorpean Language for Optical Processing) is an image manipulation language
More informationWhy do we need an interpreter? SICP Interpretation part 1. Role of each part of the interpreter. 1. Arithmetic calculator.
.00 SICP Interpretation part Parts of an interpreter Arithmetic calculator Names Conditionals and if Store procedures in the environment Environment as explicit parameter Defining new procedures Why do
More informationCS 1301 Exam 1 Fall 2010
CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in
More informationControl Structures. Important Semantic Difference
Control Structures Important Semantic Difference In all of these loops we are going to discuss, the braces are ALWAYS REQUIRED. Even if your loop/block only has one statement, you must include the braces.
More informationpsed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...]
NAME SYNOPSIS DESCRIPTION OPTIONS psed - a stream editor psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...] s2p [-an] [-e script] [-f script-file] A stream editor reads the input
More informationPerl Programming. Bioinformatics Perl Programming
Bioinformatics Perl Programming Perl Programming Regular expressions A regular expression is a pattern to be matched against s string. This results in either a failure or success. You may wish to go beyond
More informationInstallation Download and installation instructions can be found at
IntroductiontoRuby Ruby (http://www.ruby-lang.org/en/ ) is a reflective, dynamic, objectoriented, single-pass interpreted programming language. It also has some functional programming features such as
More informationThe Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1
The Three Rules Chapter 1 Beginnings Rule 1: Think before you program Rule 2: A program is a human-readable essay on problem solving that also executes on a computer Rule 3: The best way to improve your
More informationRegular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP
Regular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP address as a string and do a search. But, what if you didn
More informationPractical Questions CSCA48 Week 6
Practical Questions CSCA48 Week 6 Trace the following functions with a variety of input, and describe their functionality in a single sentence. 1. def mystery(n): if n == 4: result = n result = 2 * mystery(n+1)
More informationSample Final Exam Questions
91.301, Organization of Programming Languages Fall 2015, Prof. Yanco Sample Final Exam Questions Note that the final is a 3 hour exam and will have more questions than this handout. The final exam will
More informationCSE 154 LECTURE 11: REGULAR EXPRESSIONS
CSE 154 LECTURE 11: REGULAR EXPRESSIONS What is form validation? validation: ensuring that form's values are correct some types of validation: preventing blank values (email address) ensuring the type
More informationCS 115 Lecture 8. Selection: the if statement. Neil Moore
CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute
More informationStructure of Programming Languages Lecture 3
Structure of Programming Languages Lecture 3 CSCI 6636 4536 Spring 2017 CSCI 6636 4536 Lecture 3... 1/25 Spring 2017 1 / 25 Outline 1 Finite Languages Deterministic Finite State Machines Lexical Analysis
More informationFunctional Programming. Pure Functional Languages
Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure
More informationOverview of the Ruby Language. By Ron Haley
Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,
More informationRuby: Useful Classes and Methods
Ruby: Useful Classes and Methods Computer Science and Engineering College of Engineering The Ohio State University Lecture 6 Ranges Instance of class (Range) indices = Range.new(0, 5) But literal syntax
More informationCMSC330 Spring 2015 Midterm #1 9:30am/11:00am/12:30pm
CMSC330 Spring 2015 Midterm #1 9:30am/11:00am/12:30pm Name: Discussion Time (circle one): 10am 11am 12pm 1pm 2pm 3pm Discussion TA (circle one): Amelia Casey Chris Mike Elizabeth Eric Tommy Instructions
More informationENGR 101 Engineering Design Workshop
ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as
More informationhttps://lambda.mines.edu You should have researched one of these topics on the LGA: Reference Couting Smart Pointers Valgrind Explain to your group! Regular expression languages describe a search pattern
More informationSpace War Class Diagram. Elements of OOP. How to design interactions between objects. Space War Class Diagram with Inheritance
Elements of OOP Object Smart data structure Set of state variables Set of methods for manipulating state variables Class: Specifies the common behavior of entities Instance: A particular object or entity
More informationLecture 3. Miscellaneous Ruby and Testing 1 / 48
Lecture 3 Miscellaneous Ruby and Testing 1 / 48 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any
More informationThe Interpreter + Calling Functions. Scheme was designed by people. The Interpreter + Calling Functions. Clickers. Parentheses Matter We asked scheme
The Interpreter + Calling Functions 3 3 Why not 3 + 4 (+ 3 4) 7 (+ 3 4 5 6) 8 Here we were calling the function + The Interpreter + Calling Functions 4 (+ 3 (sqrt 6)) 7 (+ 3 4 5 6) 8 (sqrt 6) Not all procedures
More informationRegular expressions and regexp-based string operations
Regular expressions and regexp-based string operations In this chapter Regular expression syntax Pattern-matching operations The MatchData class Built-in methods based on pattern matching In this chapter,
More informationRegular Expression Reference
APPENDIXB PCRE Regular Expression Details, page B-1 Backslash, page B-2 Circumflex and Dollar, page B-7 Full Stop (Period, Dot), page B-8 Matching a Single Byte, page B-8 Square Brackets and Character
More information