CS 390 Software Engineering Lecture 6 Ruby

Size: px
Start display at page:

Download "CS 390 Software Engineering Lecture 6 Ruby"

Transcription

1 CS 390 Software Engineering Lecture 6 Ruby References: Ruby in Twenty Minutes, available at

2 Outline Clone Ruby example git repository $ git clone ssh://[user@]csserver.evansville.edu/usr/local/git/ruby-examples.git Install RVM (Ruby Version Manager). Use to install consist version of Ruby and Rails See rvm-installation file Ruby 2

3 Ruby Ruby is a scripting language, not unlike Python or PHP. Ruby can be run interactively using the irb (Interactive Ruby) interpreter. It evaluates expressions and prints out results. (puts is a command that outputs a string.) irb(main):001:0> "Hello World" => "Hello World" irb(main):002:0> puts "Hello World" Hello World irb(main):003:0> 3+2 => 5 irb(main):004:0> Math.sqrt(9) => 3.0 3

4 Functions Ruby functions are defined using reserved word def and end with reserved word end. irb(main):010:0> def hi irb(main):011:1> puts "Hello World!" irb(main):012:1> end => :hi Functions may be called with or without parentheses. E.g., using hi or hi(). 4

5 Parameters Ruby parameters are listed in parentheses. They are referenced using #{<param>} irb(main):015:0> def hi(name) irb(main):016:1> puts "Hello #{name}!" irb(main):017:1> end => :hi irb(main):018:0> hi("matz") Hello Matz! 5

6 Parameters Ruby parameters can have default values. Functions with parameters may be called without parentheses as long as it is obvious what is being done. irb(main):019:0> def hi(name = "World") irb(main):020:1> puts "Hello #{name.capitalize}!" irb(main):021:1> end => :hi irb(main):022:0> hi "chris" Hello Chris! irb(main):023:0> hi Hello World! 6

7 Classes Object types are defined using reserved word class and end with reserve word end. Data attribute names are prefixed and are private. irb(main):024:0> class Greeter irb(main):025:1> irb(main):026:2> irb(main):027:2> irb(main):028:1> irb(main):029:2> irb(main):030:2> irb(main):031:1> irb(main):032:2> irb(main):033:2> irb(main):034:1> end => :say_bye def initialize(name = "World") = name def say_hi end puts "Hi #{@name}!" def say_bye end puts "Bye #{@name}, come back soon." 7

8 Instantiation Ruby objects are instantiated using reserved method new that is a class method that calls the class' initialize method. irb(main):035:0> greeter = Greeter.new("Pat") => irb(main):036:0> greeter.say_hi Hi Pat! irb(main):037:0> greeter.say_bye Bye Pat, come back soon. 8

9 Attribute accessors Attributes can be made accessible using attr_accessor. Ruby classes can be opened after definition and new methods and accessors can be added. irb(main):044:0> class Greeter irb(main):045:1> irb(main):046:1> end => Nil attr_accessor :name irb(main):047:0> greeter = Greeter.new("Andy") => irb(main):050:0> greeter.say_hi Hi Andy! irb(main):051:0> greeter.name="betty" => "Betty" irb(main):053:0> greeter.name => "Betty" irb(main):054:0> greeter.say_hi Hi Betty! 9

10 Ruby scripts Look at ri20min.rb. First line is #!/usr/bin/env ruby Comments start with # to the end of the line Start of "main program" is if FILE == $0 to the reserved word end. FILE is an environment variable set to the name of this file. $0 is the first command-line argument (i.e. argv[0]). If they are the same, then this file is being run as a program. Otherwise it is being used as a library and this code is ignored. Run script using: ruby ri20min.rb 10

11 Ruby objects A Ruby object has Smalltalk-like behavior and can be asked if it responds to a particular method name. E.g., this can be used to distinguish between single objects and collection objects. Collections have many methods such as each and join. 11

12 Arrays Arrays can be defined explicitly giving a list in [ ]. mg.names = ["Albert", "Brenda", "Charles", "Dave", "Engelbert"] 12

Overview of the Ruby Language. By Ron Haley

Overview 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 information

CS 5142 Scripting Languages

CS 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

Introduction. CSC 440: Software Engineering Slide #1

Introduction. CSC 440: Software Engineering Slide #1 Introduction CSC 440: Software Engineering Slide #1 Topics 1. Course Goals 2. Programming: Small vs. Large 3. Challenges of Large Programs 4. Software Processes and Methods 5. Teams and Roles 6. Rails

More information

Lecture 2. Object Orientation

Lecture 2. Object Orientation Lecture 2 Object Orientation 1 Homework 0 Grades Homework 0 grades were returned earlier this week Any questions? 2 Homework 1 Homework 1 is due tonight at 11:59pm You will be graded on: Correctness: 15

More information

CSE 341, Autumn 2015, Ruby Introduction Summary

CSE 341, Autumn 2015, Ruby Introduction Summary CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful

More information

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013 CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Winter 2013 Ruby logistics Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

Ruby. Mooly Sagiv. Most slides taken from Dan Grossman

Ruby. Mooly Sagiv. Most slides taken from Dan Grossman Ruby Mooly Sagiv Most slides taken from Dan Grossman Ruby dynamic, reflective, object-oriented, general-purpose programming language Designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto

More information

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework Ruby logistics CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Autumn 2018 Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

Ruby on Rails for PHP and Java Developers

Ruby on Rails for PHP and Java Developers Ruby on Rails for PHP and Java Developers Bearbeitet von Deepak Vohra 1. Auflage 2007. Taschenbuch. xvi, 394 S. Paperback ISBN 978 3 540 73144 3 Format (B x L): 15,5 x 23,5 cm Gewicht: 629 g Weitere Fachgebiete

More information

Lecture 1. Basic Ruby 1 / 61

Lecture 1. Basic Ruby 1 / 61 Lecture 1 Basic Ruby 1 / 61 What does this do? 3.times do print 'Hello, world!' end 2 / 61 Why Ruby? Optimized for programmer happiness Used for Ruby on Rails Very popular web framework 3 / 61 Course Policies

More information

CSE 413 Spring Introduction to Ruby. Credit: Dan Grossman, CSE341

CSE 413 Spring Introduction to Ruby. Credit: Dan Grossman, CSE341 CSE 413 Spring 2011 Introduction to Ruby Credit: Dan Grossman, CSE341 Why? Because: Pure object-oriented language Interesting, not entirely obvious implications Interesting design decisions Type system,

More information

Ruby : A Dynamic Object Oriented Scripting Language

Ruby : A Dynamic Object Oriented Scripting Language Ruby : A Dynamic Object Oriented Scripting Language Gautham Anil gautham anil@cse.iitb.ac.in November 29, 2004 autham Anil gautham anil@cse.iitb.ac.in ()Ruby : A Dynamic Object Oriented Scripting Language

More information

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented Course Goal CMSC 330: Organization of Programming Languages Introduction Learn how programming languages work Broaden your language horizons! Different programming languages! Different language features

More information

Lecture 2. Object Orientation 1 / 50

Lecture 2. Object Orientation 1 / 50 Lecture 2 Object Orientation 1 / 50 Homework 1 Homework 1 was due last night You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best

More information

CMSC 330: Organization of Programming Languages. Administrivia

CMSC 330: Organization of Programming Languages. Administrivia CMSC 330: Organization of Programming Languages Administrivia 1 Course Goal Learn how programming languages work Broaden your language horizons Different programming languages Different language features

More information

! Broaden your language horizons. ! Study how languages are implemented. ! Study how languages are described / specified

! Broaden your language horizons. ! Study how languages are implemented. ! Study how languages are described / specified Course Goal CMSC 330: Organization of Programming Languages Introduction Instructors: Mike Hicks, Chau-Wen Tseng TAs: Srividya Ramaswamy, Eylul Dogruel, Khoa Doan Learn how programming languages work!

More information

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither?

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither? Computer Science Seminar Whats the next big thing? Ruby? Python? Neither? Introduction Seminar Style course unlike many computer science courses discussion important, encouraged and part of your grade

More information

PREPARING FOR PRELIM 1

PREPARING FOR PRELIM 1 PREPARING FOR PRELIM 1 CS 1110: FALL 2012 This handout explains what you have to know for the first prelim. There will be a review session with detailed examples to help you study. To prepare for the prelim,

More information

Ruby assign variable if nil. Ruby assign variable if nil.zip

Ruby assign variable if nil. Ruby assign variable if nil.zip Ruby assign variable if nil Ruby assign variable if nil.zip Assign variable only if not nil (Ruby) and I want the method below to assign value to it only if. Email codedump link for Assign variable only

More information

Introduction to Ruby. SWEN-250 Personal Software Engineering

Introduction 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 information

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions. COMP1730/COMP6730 Programming for Scientists Data: Values, types and expressions. Lecture outline * Data and data types. * Expressions: computing values. * Variables: remembering values. What is data?

More information

Lecture 2. Object Orientation 1 / 51

Lecture 2. Object Orientation 1 / 51 Lecture 2 Object Orientation 1 / 51 Homework 1 Homework 1 was due at noon You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best

More information

Introduction CMSC 330: Organization of Programming Languages. Books on Ruby. Applications of Scripting Languages

Introduction CMSC 330: Organization of Programming Languages. Books on Ruby. Applications of Scripting Languages Introduction CMSC 330: Organization of Programming Languages Ruby is an object-oriented, imperative scripting language I wanted a scripting language that was more powerful than Perl, and more object-oriented

More information

Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008.

Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008. Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008. Outline. Dynamic Allocation. Variables and Constants. Aliases and Problems. Garbage. Introduction. On Wednesday, we were talking

More information

CSE 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 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 information

Ruby AN OVERVIEW. Luigi De Russis Dipartimento di Automatica e Informatica Politecnico di Torino

Ruby AN OVERVIEW. Luigi De Russis Dipartimento di Automatica e Informatica Politecnico di Torino Ruby AN OVERVIEW Luigi De Russis Dipartimento di Automatica e Informatica Politecnico di Torino luigi.derussis@polito.it What is Ruby? Ruby is a dynamic, open source programming language with a focus on

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

Programming Paradigms

Programming 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 information

CS 390 Software Engineering Lecture 5 More Git

CS 390 Software Engineering Lecture 5 More Git CS 390 Software Engineering Lecture 5 More Git Reference: Scott Chacon and Ben Straub, Pro Git, published by Apress, available at https://git-scm.com/book/en/v2. Outline Finish local repository Remote

More information

Ruby Topic Maps. Introduction to Ruby. Benjamin Bock.

Ruby Topic Maps. Introduction to Ruby. Benjamin Bock. Ruby Topic Maps http://rtm.rubyforge.org Introduction to Ruby Benjamin Bock 1 Calculator irb(main):001:0> 1+2 Type irb in your Terminal / Command / Shell window to start the interactive Ruby interpreter

More information

Software Engineering 2 (SWT2) Chapter 2: Introduction into Ruby on Rails

Software Engineering 2 (SWT2) Chapter 2: Introduction into Ruby on Rails Software Engineering 2 (SWT2) Chapter 2: Introduction into Ruby on Rails Agenda 2 Ruby & Ruby on Rails What is Ruby on Rails? A few words about Ruby Core components RESTful architecture Active Record Your

More information

Installation Download and installation instructions can be found at

Installation 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 information

Object Model Comparisons

Object Model Comparisons Object Model Comparisons 1 Languages are designed, just like programs Someone decides what the language is for Someone decides what features it's going to have Can't really understand a language until

More information

Your First Ruby Script

Your First Ruby Script Learn Ruby in 50 pages Your First Ruby Script Step-By-Step Martin Miliauskas @mmiliauskas 1 Your First Ruby Script, Step-By-Step By Martin Miliauskas Published in 2013 by Martin Miliauskas On the web:

More information

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology Java Applets, etc. Instructor: Dmitri A. Gusev Fall 2007 CS 502: Computers and Communications Technology Lecture 25, December 5, 2007 CGI (Common Gateway Interface) CGI is a standard for handling forms'

More information

Conditionals & Control Flow

Conditionals & Control Flow CS 1110: Introduction to Computing Using Python Lecture 8 Conditionals & Control Flow [Andersen, Gries, Lee, Marschner, Van Loan, White] Announcements: Assignment 1 Due tonight at 11:59pm. Suggested early

More information

Lecture 18 Tao Wang 1

Lecture 18 Tao Wang 1 Lecture 18 Tao Wang 1 Abstract Data Types in C++ (Classes) A procedural program consists of one or more algorithms that have been written in computerreadable language Input and display of program output

More information

CSE 341: Programming Languages

CSE 341: Programming Languages CSE 341: Programming Languages Hal Perkins Spring 2011 Lecture 19 Introduction to Ruby Hal Perkins CSE341 Spring 2011, Lecture 19 1 Today Why Ruby? Some basics of Ruby programs Syntax Classes, Methods

More information

Ruby on Rails. SITC Workshop Series American University of Nigeria FALL 2017

Ruby on Rails. SITC Workshop Series American University of Nigeria FALL 2017 Ruby on Rails SITC Workshop Series American University of Nigeria FALL 2017 1 Evolution of Web Web 1.x Web 1.0: user interaction == server roundtrip Other than filling out form fields Every user interaction

More information

CS 320 Introduction to Software Engineering Spring February 06, 2017

CS 320 Introduction to Software Engineering Spring February 06, 2017 CS 320 Introduction to Software Engineering Spring 2017 February 06, 2017 Recap: Software development process models Traditional models Waterfall model Iterative and incremental Prototyping Spiral model

More information

Array variable in class ruby. Array variable in class ruby.zip

Array variable in class ruby. Array variable in class ruby.zip Array variable in class ruby Array variable in class ruby.zip Returns a new array. In the first form, if no arguments are sent, the new array will be empty. When a size and an optional obj are sent, an

More information

Assignment 1 due Monday at 11:59pm

Assignment 1 due Monday at 11:59pm Assignment 1 due Monday at 11:59pm The heart of Object-Oriented Programming (Now it gets interesting!) Reading for next lecture is Ch. 7 Focus on 7.1, 7.2, and 7.6 Read the rest of Ch. 7 for class after

More information

Having Fun with Social Coding. Sean Handley. February 25, 2010

Having Fun with Social Coding. Sean Handley. February 25, 2010 Having Fun with Social Coding February 25, 2010 What is Github? GitHub is to collaborative coding, what Facebook is to social networking 1 It serves as a web front-end to open source projects by allowing

More information

61A Lecture 2. Friday, August 28, 2015

61A Lecture 2. Friday, August 28, 2015 61A Lecture 2 Friday, August 28, 2015 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions: max

More information

Lecture 1. basic Python programs, defining functions

Lecture 1. basic Python programs, defining functions Lecture 1 basic Python programs, defining functions Lecture notes modified from CS Washington CS 142 Except where otherwise noted, this work is licensed under: http://creativecommons.org/licenses/by-nc-sa/3.0

More information

Object-Oriented Modeling Using UML. CS151 Chris Pollett Aug. 29, 2005.

Object-Oriented Modeling Using UML. CS151 Chris Pollett Aug. 29, 2005. Object-Oriented Modeling Using UML CS151 Chris Pollett Aug. 29, 2005. Outline Objects and Classes Modeling Relationships and Structures Some Terms and Concepts Objects and classes are fundamental to OO

More information

Ruby, with foxes. Ruby, cont d. Warning. why's (poignant) Guide to Ruby

Ruby, with foxes. Ruby, cont d. Warning. why's (poignant) Guide to Ruby O Ruby, cont d n O Ruby, with foxes n why's (poignant) Guide to Ruby Ruby explained through humorous and more or less irrelevant stories about foxes, elfs, cats and others Warning If I was put off Ruby

More information

Immutability and Design Patterns in Ruby

Immutability and Design Patterns in Ruby Immutability and Design Patterns in Ruby Seamus Brady, seamus@corvideon.ie 28/03/2013 Abstract Functional Programming has seen a resurgence in interest in the last few years and is often mentioned in opposition

More information

Object Oriented Programming in Python 3

Object Oriented Programming in Python 3 Object Oriented Programming in Python 3 Objects Python 3 Objects play a central role in the Python data model All the types we ve seen until now are in-fact objects Numeric types, strings, lists, tuples,

More information

Ruby on Rails TKK, Otto Hilska

Ruby on Rails TKK, Otto Hilska Ruby on Rails intro @ TKK, 25.5.2009 Otto Hilska 1 Today s agenda 1. The Ruby programming language 2. Ruby on Rails framework 3. An example project 2 About me Started Nodeta Oy in 2004 10+ employees always

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Remember: quiz about the course AI policy Have posted grades for completed quizes Right now, missing ~130 enrolled students If did not receive at least

More information

Dynamically-typed Languages. David Miller

Dynamically-typed Languages. David Miller Dynamically-typed Languages David Miller Dynamically-typed Language Everything is a value No type declarations Examples of dynamically-typed languages APL, Io, JavaScript, Lisp, Lua, Objective-C, Perl,

More information

Lecture 4: Defining Functions (Ch ) CS 1110 Introduction to Computing Using Python

Lecture 4: Defining Functions (Ch ) CS 1110 Introduction to Computing Using Python http://www.cs.cornell.edu/courses/cs0/209sp Lecture 4: Defining Functions (Ch..4-.) CS 0 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White]

More information

COMP519 Web Programming Lecture 12: JavaScript (Part 3) Handouts

COMP519 Web Programming Lecture 12: JavaScript (Part 3) Handouts COMP519 Web Programming Lecture 12: JavaScript (Part 3) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

Day 2: 19/April/2012 Installing Aptana IDE; Integrated Development Environment And Rails

Day 2: 19/April/2012 Installing Aptana IDE; Integrated Development Environment And Rails Day 2: 19/April/2012 Installing Aptana IDE; Integrated Development Environment And Rails p Setting Up Aptana IDE n IDE; Integrated Development Environment n Set Up Japanese Language Support n Run rails

More information

61A Lecture 2. Wednesday, September 4, 2013

61A Lecture 2. Wednesday, September 4, 2013 61A Lecture 2 Wednesday, September 4, 2013 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions:

More information

CS 390 Software Engineering Lecture 3 Configuration Management

CS 390 Software Engineering Lecture 3 Configuration Management CS 390 Software Engineering Lecture 3 Configuration Management Includes slides from the companion website for Sommerville, Software Engineering, 10/e. Pearson Higher Education, 2016. All rights reserved.

More information

Ruby Primer and Review for Developers

Ruby Primer and Review for Developers A PPENDIX A Ruby Primer and Review for Developers This T appendix is designed to act as both a Ruby primer and review, useful both to developers who want to brush up rapidly on their Ruby knowledge, and

More information

LibSerial Documentation

LibSerial Documentation LibSerial Documentation Release 1.0.0rc1 CrayzeeWulf Apr 05, 2018 Contents: 1 Feature Summary 3 2 Description 5 3 Download 7 4 Install 9 5 Tutorial 11 5.1 Opening a Serial Port I/O Stream....................................

More information

CHAPTER 3: CORE PROGRAMMING ELEMENTS

CHAPTER 3: CORE PROGRAMMING ELEMENTS Variables CHAPTER 3: CORE PROGRAMMING ELEMENTS Introduction to Computer Science Using Ruby A variable is a single datum or an accumulation of data attached to a name The datum is (or data are) stored in

More information

Pairs and Lists. (cons 1 2) 1 2. (cons 2 nil) 2 nil. Not a well-formed list! 1 > (cdr x) 2 > (cons 1 (cons 2 (cons 3 (cons 4 nil)))) ( ) (Demo)

Pairs and Lists. (cons 1 2) 1 2. (cons 2 nil) 2 nil. Not a well-formed list! 1 > (cdr x) 2 > (cons 1 (cons 2 (cons 3 (cons 4 nil)))) ( ) (Demo) 61A Lecture 25 Announcements Pairs Review Pairs and Lists In the late 1950s, computer scientists used confusing names cons: Two-argument procedure that creates a pair car: Procedure that returns the first

More information

SCHEME AND CALCULATOR 5b

SCHEME 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 information

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 http://xkcd.com/353/ Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 Python Python is a general-purpose programming language, meaning you can write any kind

More information

CSc 372 Comparative Programming Languages

CSc 372 Comparative Programming Languages CSc 372 Comparative Programming Languages 1 : Introduction Christian Collberg collberg+372@gmail.com Department of Computer Science University of Arizona Copyright c 2007 Christian Collberg [1] Why learn

More information

CSc 372. Comparative Programming Languages. 1 : Introduction. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 1 : Introduction. Department of Computer Science University of Arizona Christian Collberg CSc 372 Comparative Programming Languages 1 : Introduction Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2011 Christian Collberg Why learn programming

More information

At the Forge. What Is Ruby? Getting Started with Ruby. Reuven M. Lerner. Abstract

At the Forge. What Is Ruby? Getting Started with Ruby. Reuven M. Lerner. Abstract 1 of 6 6/18/2006 8:38 PM At the Forge Getting Started with Ruby Reuven M. Lerner Abstract What's behind all the Ruby hype? Reuven walks us through a couple of examples to let the code speak for itself.

More information

Boldface numbers indicate illustrations, code listings, and tables.

Boldface numbers indicate illustrations, code listings, and tables. Index Boldface numbers indicate illustrations, code listings, and tables. A ActiveRecord, class in Ruby, 80-82, 84, 86, 88, 90 ActiveXMLService, class in Ruby, 80-82, 84, 90 Agile development, 109-110

More information

Final thoughts on functions F E B 2 5 T H

Final thoughts on functions F E B 2 5 T H Final thoughts on functions F E B 2 5 T H Ordering functions in your code Will the following code work? Here the function is defined after the main program that is calling it. print foo() def foo(): return

More information

Chapter 10 Introduction to Classes

Chapter 10 Introduction to Classes C++ for Engineers and Scientists Third Edition Chapter 10 Introduction to Classes CSc 10200! Introduction to Computing Lecture 20-21 Edgardo Molina Fall 2013 City College of New York 2 Objectives In this

More information

COMP1730/COMP6730 Programming for Scientists. Functional abstraction, with robots

COMP1730/COMP6730 Programming for Scientists. Functional abstraction, with robots COMP1730/COMP6730 Programming for Scientists Functional abstraction, with robots Lecture outline * The warehouse robot * Functional abstraction * The python language: First steps. The robot * Drive left/right

More information

CP215 Application Design

CP215 Application Design CP215 Application Design Microsoft HoloLens developer preorder: $3,000 Tech News! Tech News! Microsoft HoloLens developer preorder: $3,000 Raspberry Pi 3 with Wi-Fi and Bluetooth built-in: $35 Hacker's

More information

COMP1730/COMP6730 Programming for Scientists. Functions

COMP1730/COMP6730 Programming for Scientists. Functions COMP1730/COMP6730 Programming for Scientists Functions Lecture outline * Function definition. * Function calls & order of evaluation. * Assignments in functions; local variables. * Function testing. Functions

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

CS 390 Software Engineering Lecture 4 - Git

CS 390 Software Engineering Lecture 4 - Git CS 390 Software Engineering Lecture 4 - Git Reference: Scott Chacon and Ben Straub, Pro Git, published by Apress, available at https://git-scm.com/book/en/v2. Outline Git terminology Git configuration

More information

What is Ruby? CSc 372. Comparative Programming Languages. 27 : Ruby Introduction. Department of Computer Science University of Arizona

What is Ruby? CSc 372. Comparative Programming Languages. 27 : Ruby Introduction. Department of Computer Science University of Arizona What is Ruby? CSc 372 Comparative Programming Languages 27 : Ruby Introduction Department of Computer Science University of Arizona Everything is an object. Everything can be changed: method can be added

More information

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

More information

Introduction to Ruby on Rails

Introduction to Ruby on Rails Introduction to Ruby on Rails Ralf Teusner ralf.teusner@hpi.de Software Engineering II WS 2018/19 Prof. Plattner, Dr. Uflacker Enterprise Platform and Integration Concepts group Introduction to Ruby on

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Remember: quiz about the course AI policy Have posted grades for completed quizes Right now, missing ~90 enrolled students If did not receive perfect,

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Introduction Instructors: Michael Hicks and Anwar Mamat CMSC 330 1 Course Goal Learn how programming languages work Broaden your language horizons Different

More information

COMP 250 Winter 2011 Reading: Java background January 5, 2011

COMP 250 Winter 2011 Reading: Java background January 5, 2011 Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP

More information

Course Goal CMSC 330: Organization of Programming Languages. All Languages Are (Kind of) Equivalent. Studying Programming Languages.

Course Goal CMSC 330: Organization of Programming Languages. All Languages Are (Kind of) Equivalent. Studying Programming Languages. Course Goal CMSC 330: Organization of Programming Languages Introduction Dr. Anwar Mamat Learn how programming languages work Broaden your language horizons Different programming languages Different language

More information

TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13

TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13 TDDB84: Lecture 09 SOLID, Language design, Summary SOLID Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Depency inversion principle

More information

Introduction to Python. Didzis Gosko

Introduction to Python. Didzis Gosko Introduction to Python Didzis Gosko Scripting language From Wikipedia: A scripting language or script language is a programming language that supports scripts, programs written for a special run-time environment

More information

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 CS 133 - Introduction to Computational and Data Science Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 Previous class We have learned the path and file system.

More information

CS1 Lecture 4 Jan. 24, 2018

CS1 Lecture 4 Jan. 24, 2018 CS1 Lecture 4 Jan. 24, 2018 First homework due Mon., 9:00am Meet specifications precisely. Functions only. Use a file editor! Don t type functions/long sections of code directly into Python interpreter.

More information

JavaScript: Introduction, Types

JavaScript: Introduction, Types JavaScript: Introduction, Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 19 History Developed by Netscape "LiveScript", then renamed "JavaScript" Nothing

More information

Intro. Scheme Basics. scm> 5 5. scm>

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

Intro to Ruby Scripting

Intro to Ruby Scripting Intro to Ruby Scripting http://phys.lsu.edu/~galanakis/resources/ruby_talk.pdf Dimitrios Galanakis Thursday April 15th A Tutorial for the LSU Center for Computation and Technology Why Scripting? Advantages

More information

Configuring Condor with Wallaby. William C. Benton and Robert H. Rati Red Hat, Inc.

Configuring Condor with Wallaby. William C. Benton and Robert H. Rati Red Hat, Inc. Configuring Condor with Wallaby William C. Benton and Robert H. Rati Red Hat, Inc. http://www.redhat.com/mrg http://getwallaby.com 1 Forecast Background Getting started with Wallaby Using the Wallaby tools

More information

Ruby: Introduction, Basics

Ruby: 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 information

Imperative vs. objectoriented

Imperative vs. objectoriented CSCI-2320 Object-Oriented Paradigm: Ruby Mohammad T. Irfan Imperative vs. objectoriented paradigms 1 Imperative vs. object-oriented u Imperative u Procedural decomposition u Procedures are all powerful

More information

Strings and Variables

Strings and Variables Strings and Variables class Player attr_accessor :name attr_reader :health def initialize(name, health=100) @name = name.capitalize @health = health @found_treasures = Hash.new(0) Inside the initialize

More information

RUBY RUBY BY E X A MPLE

RUBY RUBY BY E X A MPLE RUBY E XPLORING FUNCTIONAL CODE Baird s examples demonstrate key features of the language (such as inheritance, encapsulation, higherorder functions, and recursion), while simultaneously solving difficult

More information

https://lambda.mines.edu Object oriented programming is a type of programming with objects that maintain internal state and pass messages between each other. First appeared in the mid-1960s in Simula:

More information

S206E Lecture 19, 5/24/2016, Python an overview

S206E Lecture 19, 5/24/2016, Python an overview S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

More information

CS 3813/718 Fall Python Programming. Professor Liang Huang.

CS 3813/718 Fall Python Programming. Professor Liang Huang. CS 3813/718 Fall 2012 Python Programming Professor Liang Huang huang@cs.qc.cuny.edu http://vision.cs.qc.cuny.edu/huang/python-2012f/ Logistics Lectures: TTh 9:25-10:40 am SB B-141 Personnel Instructor

More information

This tutorial has been prepared for beginners to help them understand the basic to advanced concepts related to Ruby Scripting languages.

This tutorial has been prepared for beginners to help them understand the basic to advanced concepts related to Ruby Scripting languages. About the Tutorial Ruby is a scripting language designed by Yukihiro Matsumoto, also known as Matz. It runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This tutorial

More information

Programming Languages & Paradigms PROP HT Course Council. Subprograms. Meeting on friday! Subprograms, abstractions, encapsulation, ADT

Programming Languages & Paradigms PROP HT Course Council. Subprograms. Meeting on friday! Subprograms, abstractions, encapsulation, ADT Programming Languages & Paradigms PROP HT 2011 Lecture 4 Subprograms, abstractions, encapsulation, ADT Beatrice Åkerblom beatrice@dsv.su.se Course Council Meeting on friday! Talk to them and tell them

More information