Introduction to Scheme Lectures on The Scheme Programming Language, 2 nd Ed. R. Kent Dybvig.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Functional Programming. Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
Lecture-5 Though SQL is the natural language of the DBA, it suffers from various inherent disadvantages, when used as a conventional programming language.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
Chapter 2: Introduction to C++.
JavaScript, Third Edition
1 Lecture 3  Lexical elements  Some operators:  /, %, =, +=, ++, --  precedence and associativity  #define  Readings: Chapter 2 Section 1 to 10.
SCHEME By: Krista and Brett. What is Scheme? Best known for its functional style of programming One of two main dialects of Lisp Developed in 1975 –MIT.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Slide 1 Vitaly Shmatikov CS 345 Introduction to Scheme.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
The Java Programming Language
Scheme & Functional Programming. ( ) >> 64 ( ) >> 666 (* ) >> 1200 (+ (* 3 5) (- 10 6)) >> 19.
Input, Output, and Processing
Introduction to Scheme CS 480/680 – Comparative Languages “And now for something completely different…” – Monty Python “And now for something completely.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Recognizing PL/SQL Lexical Units. 2 home back first prev next last What Will I Learn? List and define the different types of lexical units available in.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Introduction to Computer Programming
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
C++ for Engineers and Scientists Second Edition
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
CS314 – Section 5 Recitation 9
CS314 – Section 5 Recitation 10
Topics Designing a Program Input, Processing, and Output
Chapter 2: Introduction to C++
CS 326 Programming Languages, Concepts and Implementation
Overview of Compilation The Compiler Front End
Overview of Compilation The Compiler Front End
Introduction to Scheme
Java Programming: From Problem Analysis to Program Design, 4e
Chapter 2: Introduction to C++
2.1 Parts of a C++ Program.
Introduction to C++ Programming
Chapter 2: Basic Elements of Java
T. Jumana Abu Shmais – AOU - Riyadh
Lecture 4: Lexical Analysis & Chomsky Hierarchy
Introduction to Primitive Data types
CS 36 – Chapter 11 Functional programming Features Practice
Lisp and Scheme I.
6.001 SICP Variations on a Scheme
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Modern Programming Languages Lecture 18 Fakhar Lodhi
Introduction to Primitive Data types
Presentation transcript:

Introduction to Scheme Lectures on The Scheme Programming Language, 2 nd Ed. R. Kent Dybvig

Compiler Implementation Source Code Compiler Object Code Linker Executable code Object Modules

Interpreter Implementation Source Code Interpreter Code Input - Source code is data for the interpreter - Interpreter code is executed directly on the machine

Dr. Scheme Available at Scheme interpreter Select Language, Choose Language, How to Design Programs, Essentials of Programming Languages (2 nd Ed.) Screen divided into 2 areas

Introduction to Scheme Data values are allocated on the heap Objects are “first class” – can be passed in and out of procedures Variables are lexically scoped (define x 3) (let ((x 2) (y 5)) (+ x y))

Introduction to Scheme Programs are “block structured” (define x (lambda (x) (+ x x))) Blocks can be nested (let ((x 2) (y 5)) (let ((x 6)) (+ x y)))

Introduction to Scheme Procedures can be defined at the top level, or within another block (define incr (lambda (a) (+ a 1))) (let ((incr (lambda (a) (+ a 1))) (x 3)) (incr x))

Introduction to Scheme Procedures are first class objects (define square (lambda (x) (* x x))) (define double (lambda (x) (+ x x))) (define apply (lambda (fn p) (fn p))) (apply square 3) (apply double 4)

Introduction to Scheme Procedures can be unnamed ((lambda (x y)(+ x y)) 3 4) Procedures can be named (define add (lambda (x y)(+ x y))) (add 3 4)

Introduction to Scheme Scheme supports recursive functions (define factorial (lambda (x) (cond ((= x 1) 1) (else (* x (factorial (- x 1))))))) (factorial 100)

Scheme Syntax Scheme programs are made up of keywords, variables, structured forms, constant data (numbers, characters, strings, quoted vectors, quoted lists, quoted symbols, etc.), whitespace, and comments.

Scheme Syntax Keywords, variables, and symbols are collectively called identifiers. Identifiers may be formed from the following set of characters: a – z, A – Z, 0 – 9, ? !. + - * / : $ % ^ & _ ~ Identifiers normally cannot start with any character that may start a number

Scheme Syntax No inherent limit on the length of a Scheme identifier Structured forms and list constants are enclosed within parentheses, e.g., (a b c) or (* (- x 2) y). The empty list is written () Boolean values representing true and false are written as #t and #f

Scheme Syntax Vectors are preceded by #( and terminated by ). #(a b c d) Strings are enclosed in double quotation marks. " This is a string" Characters are preceded by #\. #\a. Numbers may be written as integers, ratios, floating-point,or scientific notation, or as complex numbers in rectangular or polar notation, 123, ½, 1e23,

Scheme Syntax Comments appear between a semicolon ( ; ) and the end of the line.

Scheme Naming Conventions Predicate names end in a question mark ( ? ). eq?, zero?, and string=?. Common numeric comparators =,, = are exceptions to this rule Most character, string, and vector procedure names start with the prefix char-, string-, and vector-, e.g., string- append

Scheme Naming Conventions Names of procedures that convert an object of one type into an object of another type are written as type1- >type2, e.g., vector->list. Names of procedures and syntactic forms that cause side effects end with an exclamation point ( ! ). set! and vector-set!