Introduction, Functions

Similar documents
Introduction to Functional Programming. Slides by Koen Claessen and Emil Axelsson

Who and what can help? Inf1-OP. Lecturer: Timothy Hospedales TA: Natalia Zon

Inf1-OOP. Textbooks. Who and What. Organizational Issues. Why Java? Course Overview. Hello, World! in Java. Ewan Klein, Perdita Stevens

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java

Course and Unix Intro


Welcome to CS 135 (Winter 2018)

Announcements. 1. Forms to return today after class:

COSE212: Programming Languages. Lecture 0 Course Overview

CS240: Programming in C

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Introduction to Computer Systems

IA010: Principles of Programming Languages

Welcome to CS 135 (Fall 2018) Themes of the course. Lectures. cs135/

Introduction to Nate Foster Spring 2018

Introduction to Databases Fall-Winter 2010/11. Syllabus

COS 326 Func,onal Programming: An elegant weapon for the modern age David Walker Princeton University

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CSC 111 Introduction to Computer Science (Section C)

Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department

COS 326 Functional programming: an elegant weapon for the modern age

Inf1-OP. Course Overview. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Lecture 1. Course Overview, Python Basics

ITT8060 Advanced Programming

Programming 2. Outline (112) Lecture 0. Important Information. Lecture Protocol. Subject Overview. General Overview.

An introduction to R: Organisation and Basics of Algorithmics

Today. An Animated Introduction to Programming. Prerequisites. Computer programming

Introduction to Data Structures

Practical Programming Methodology

Lecture 1. Course Overview, Python Basics

Database Systems (INFR10070) Dr Paolo Guagliardo. University of Edinburgh. Fall 2016

Classical Internet Applications

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Course Overview, Python Basics

Unit 7: Algorithms and Python CS 101, Fall 2018

Informatics 1: Data & Analysis

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

Welcome to... CS113: Introduction to C

CSc 520. Course Outline (Subject to change) Course Outline (Subject to change)... Principles of Programming Languages. Christian Collberg

CMPUT 391 Database Management Systems. Fall Semester 2006, Section A1, Dr. Jörg Sander. Introduction

Course Syllabus - CNT 4703 Design and Implementation of Computer Communication Networks Fall 2011

CNT 4004: Computer Networks I. Tentative Syllabus


COMP-202: Foundations of Programming. Lecture 26: Review; Wrap-Up Jackie Cheung, Winter 2016

Programming Language Concepts, cs2104 Lecture 01 ( )

CprE 281: Digital Logic

College Algebra. Cartesian Coordinates and Graphs. Dr. Nguyen August 22, Department of Mathematics UK

Programming Languages and Compilers (CS 421)

FIT3056 Secure and trusted software systems. Unit Guide. Semester 2, 2010

Compiling Techniques

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

CS Introduction to Programming Fall 2016

Informatics 1: Data & Analysis

Programming 1. Outline (111) Lecture 0. Important Information. Lecture Protocol. Subject Overview. General Overview.

Lecture 1: Introduction, Types & Expressions

Advanced Programming Concepts. CIS 15 : Spring 2007

Introduction to Computer Science I

What is programming? Elements of Programming Languages. From machine code to programming languages. What is a programming language?

Programming Languages. So why study PL? A Programming Language. A different language is a different vision of life. CSE 130 : Fall 2015

Programming Languages. So why study PL? A Programming Language. A different language is a different vision of life. CSE 130 : Spring 2015

CS457/557 Functional Languages

EE3315 Internet Technology EE3315 Internet Technology Overview Slide 1

Unit 10: Data Structures CS 101, Fall 2018

CSE 341: Programming Languages

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

Functional Programming Principles in Scala. Martin Odersky

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

Introduction (1) COMP 520: Compiler Design (4 credits) Alexander Krolik MWF 13:30-14:30, MD 279

Programming Languages and Techniques (CIS120)

Announcements. Course syllabus Tutorial/lab signup form (due 4pm today) Lecture 1 notes Homework 1 Initial assessment

Introduction to Computer Systems

Office Hours Time: Monday/Wednesday 12:45PM-1:45PM (SB237D) More Information: Office Hours Time: Monday/Thursday 3PM-4PM (SB002)

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

CS558 Programming Languages

CS1 Lecture 3 Jan. 18, 2019

Connect to CCPL

CMPE 150/L : Introduction to Computer Networks

Inf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

INF 315E Introduction to Databases School of Information Fall 2015

Objectives. Structure. Munster Programming Training

Memory Allocation II. CSE 351 Autumn Instructor: Justin Hsia

Inf1-OOP. OOP Exam Review. Perdita Stevens, adapting earlier version by Ewan Klein. March 16, School of Informatics

Computers and programming languages introduction

Informatics 1 Functional Programming Lectures 13 and 14 Monday 11 and Tuesday 12 November Type Classes. Don Sannella University of Edinburgh

CS 3110 Lecture 1 Course Overview

CPSC 4600 Biometrics and Cryptography Fall 2013, Section 0

CSC 261/461 Database Systems. Fall 2017 MW 12:30 pm 1:45 pm CSB 601

CSC116: Introduction to Computing - Java

ECE 156A - Syllabus. Description

Programming (Econometrics)

Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont)

TIETS14 Introduction to Formal Specification

CSE 504: Compiler Design

Object-Oriented Programming Classes, Objects, Variables

Turtle Graphics and L-systems Informatics 1 Functional Programming: Tutorial 7

Introduction to Databases Fall-Winter 2009/10. Syllabus

Transcription:

Informatics 1 Functional Programming Lectures 1 and 2 Introduction, Functions Don Sannella University of Edinburgh

Welcome to Informatics 1, Functional Programming! Informatics 1 course organiser: Paul Anderson Functional programming (Inf1-FP) Lecturer: Don Sannella Teaching assistant: Karoliina Lehtinen Computation and logic (Inf1-CL) Lecturer: Michael Fourman Teaching assistant:??? Informatics Teaching Organization (ITO): Gregor Hall

Where to find us IF Informatics Forum FH Forrest Hill Inf1 course organiser: Paul Anderson dcspaul@inf.ed.ac.uk IF 1.24 Functional programming (Inf1-FP) Lecturer: Don Sannella Don.Sannella@ed.ac.uk IF 5.12 Teachingassistant:KaroliinaLehtinen M.K.Lehtinen@sms.ed.ac.uk IF 5.34 Informatics Teaching Organization (ITO): Gregor Hall FH 1.B15

Required text and reading Haskell: The Craft of Functional Programming (Third Edition), Simon Thompson, Addison-Wesley, 2011. or Learn You a Haskell for Great Good! Miran Lipovača, No Starch Press, 2011. Reading assignment Monday 21 September 2015 Thompson: parts of Chap. 1-3 Lipovača: parts of intro, Chap. 1-2 Monday 28 September 2015 etc. See the course web page The assigned reading covers the material very well with plenty of examples. There will be no lecture notes, just the books. Get one of them and read it!

Linux / DICE Tutorial Tuesday 22 September 2015 2 4pm Forrest Hill Drill Hall Wednesday 23 September 2015 2 4pm Forrest Hill Drill Hall Thursday 24 September 2015 2 4pm Forrest Hill Drill Hall Forrest Hill Drill Hall, FH 1.B30

Lab Week Exercise and Drop-In Labs Monday 3 5pm (demonstrator 3:00-4:00pm) Forrest Hill Drill Hall Tuesday 2 5pm (demonstrator 3:00-4:00pm) Forrest Hill Drill Hall Wednesday 2 5pm (demonstrator 3:00-4:00pm) Forrest Hill Drill Hall Thursday 2 5pm (demonstrator 3:00-4:00pm) Forrest Hill Drill Hall Friday 3 5pm (demonstrator 3:00-4:00pm) Forrest Hill Drill Hall Forrest Hill Drill Hall, FH 1.B30 Lab Week Exercise submit by 5pm Friday 2 October 2015 Do all the parts

Tutorials ITO will assign you to tutorials, which start in Week 3. Attendance is compulsory. Tuesday/Wednesday Thursday/Friday Computation and Logic Functional Programming Contact the ITO if you need to change to a tutorial at a different time. You must do each week s tutorial exercise! Do it before the tutorial! Bring a printout of your work to the tutorial! You may collaborate, but you are responsible for knowing the material. Mark of 0% on tutorial exercises means you have no incentive to plagiarize. But you will fail the exam if you don t do the tutorial exercises!

Automated Feedback CamlBack (UCLA) will give automated feedback on tutorial exercises. Use is optional, but it s good to get immediate feedback.

Automated Feedback CamlBack (UCLA) will give automated feedback on tutorial exercises. Use is optional, but it s good to get immediate feedback.

Formative vs. Summative 0% Lab week exercise 0% Tutorial 1 0% Tutorial 2 0% Tutorial 3 10% Class Test 0% Tutorial 4 0% Tutorial 5 0% Tutorial 6 0% Tutorial 7 0% Mock Exam 0% Tutorial 8 90% Final Exam

Course Webpage See http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/ for: Course content Organisational information: what, where, when Lecture slides, reading assignment, tutorial exercises, solutions Past exam papers Programming competition Other resources

Any questions? Questions make you look good! Don s secret technique for asking questions. Don s secret goal for this course

Piazza Use the Piazza online Inf1-FP forum: For asking questions outside lectures For reading answers to questions asked by others For writing answers to questions asked by others See the course webpage for the link and for sign-up instructions

Part I Introduction

Why learn Haskell? Important to learn many languages over your career Functional languages increasingly important in industry Puts experienced and inexperienced programmers on an equal footing Operate on data structure as a whole rather than piecemeal Good for concurrency, which is increasingly important

Linguistic Relativity Language shapes the way we think, and determines what we can think about. Benjamin Lee Whorf, 1897 1941 The limits of my language mean the limits of my world. Ludwig Wittgenstein, 1889 1951 A language that doesn t affect the way you think about programming, is not worth knowing. Alan Perlis, 1922 1990

Look at these web pages: ICFP 2015 icfpconference.org/icfp2015/ Jane Street Capital www.janestreet.com/technology/ www.wired.com/2015/09/ Facebook facebooks-new-anti-spam-system-hints-future-coding/

Families of programming languages Functional Erlang, F#, Haskell, Hope, Javascript, Miranda, OCaml, Racket, Scala, Scheme, SML More powerful More compact programs Object-oriented C++, F#, Java, Javascript, OCaml, Perl, Python, Ruby, Scala More widely used More libraries

Functional programming in the real world Google MapReduce, Sawzall Ericsson AXE phone switch Perl 6 DARCS XMonad Yahoo Twitter Facebook Garbage collection

Functional programming is the new new thing Erlang, F#, Scala attracting a lot of interest from developers Features from functional languages are appearing in other languages Garbage collection Java, C#, Python, Perl, Ruby, Javascript Higher-order functions Java, C#, Python, Perl, Ruby, Javascript Generics Java, C# List comprehensions C#, Python, Perl 6, Javascript Type classes C++ concepts

Part II Functions

What is a function? A recipe for generating an output from inputs: Multiply a number by itself A set of (input, output) pairs: (1,1) (2,4) (3,9) (4,16) (5,25)... An equation: f x = x 2 A graph relating inputs to output (for numbers only):

Kinds of data Integers: 42, -69 Floats: 3.14 Characters: h Strings: "hello" Booleans: True, False Pictures:

Applying a function invert :: Picture -> Picture knight :: Picture invert knight invert

Composing functions beside :: Picture -> Picture -> Picture flipv :: Picture -> Picture invert :: Picture -> Picture knight :: Picture beside (invert knight) (flipv knight) invert beside flipv

Defining a new function double :: Picture -> Picture double p = beside (invert p) (flipv p) double knight double invert beside flipv

Defining a new function double :: Picture -> Picture double p = beside (invert p) (flipv p) double knight double

Terminology Type signature double :: Picture -> Picture Function declaration double p = beside (invert p) (flipv p) function name function body

Terminology formal parameter actual parameter double p = beside (invert p) (flipv p) double knight function definition expression