# Introduction 2 Lisp Part I

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Introduction 2 Lisp Part I Andreas Wichert LEIC-T (Página da cadeira: Fenix) Corpo docente n Andreas (Andrzej) Wichert Praticas n n tel: n room: N2 5-7 n 1

2 Horário de dúvidas n 5º-feira, 14H-17H, 2-N5.7 Guess: What does LISP stand for? n Looney Idiotic Stupid Professor? n Long Incomprehensible String of Parentheses? n LISt Processing? 2

3 What is LISP? n Originated by John McCarthy (September 4, 1927 October 24, 2011) n In 1959 as an implementation of recursive function theory n 3

4 What is LISP? n Conditionals - if-then-else construct n A function type - functions are first-class objects n Recursion n Typed values rather than typed variables n Garbage collection (interpreter) n Programs made entirely of functional expressions that return values Uses Polish notation n The description "Polish" refers to the nationality of logician Jan Łukasiewicz, (21 December February 1956) who invented (prefix) Polish notation in the 1920s n Polish notation, also known as Polish prefix notation or simply prefix notation 4

5 n (5 6) 7= n Can be written as n ( ( 5 6) 7) n When Polish notation is used as a syntax for mathematical expressions by programming language interpreters, it is readily parsed into abstract syntax trees and can, in fact, define a one-toone representation for the same 5

6 n ((15 (7 (1 + 1))) 3) (2 + (1 + 1)) = 5 n ((15 (7 (1 + 1))) 3) (2 + (1 + 1)) = 5 n In Lisp n (- (* (/ 15 (- 7 (+ 1 1))) 3) (+ 2 (+ 1 1)))) 5 6

7 Literature n Practical Common Lisp, Peter Seibel, 2005, Apress, versaõ online n ANSI Common Lisp, Paul Graham, 1995, Prentice Hall, versaõ online n Introduc aõ a Linguagem Lisp, Antońio Leitaõ, 1995, Instituto Superior Tećnico My recommendation. LAND OF LISP, Conrad Barski, 2010, No Starch Press, A very good first contact with the world of Lisp! "Turns out the border between genius and insanity is a pretty cheery place" says Paul Graham! Land of Lisp - The Music Video (Home Work 1, watch the video) 7

9 n Dana Nau n Introduction to Lisp / AI material n We will use Common lisp J n Purpose of Common Lisp: to unify the main dialects n Thus it contains multiple constructs to do the same things n Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS (R2004) (formerly X (R1999)). 9

10 Installing Common Lisp n CLISP n Download a CLISP installer from n Running clisp 10

11 Clozure Common Lisp n n Like all Common Lisp environments, CLISP will automatically place you into a read-eval-print loop (REPL) n The code on the previous slide runs interpretively A few Common Lisps will compile the code every time you load it n Compiling makes your programs run faster, and may detect some errors 11

12 Evaluating >1 1 >pi L0 > t T > nil NIL 12

13 Symbols n Common Lisp symbols are typically made up of letters, numbers, and characters like + - / * = < >?! _ n ice9, my-killer-app27, and even -- <<==>>--. 13

14 Numbers > ( ) 2.0 > (expt 53 53) > (/ 4 6) 2/3 > (/ 4.0 6) > ( ) -8 Why? Evaluates from left >(- (- 5 6) 7) -8 14

15 Strings (princ "Tutti Frutti") Tutti Frutti "Tutti Frutti" n The text appears twice n First, we see the actual printing caused by the princ command. n REPL will always show the result of evaluating the entered expression the princ function returns a value, the source string. > (princ "He yelled \"Stop that thief!\" from the busy street.") He yelled "Stop that thief!" from the busy street. "He yelled \"Stop that thief!\" from the busy street." 15

16 Code Mode n > (expt 2 3) n 8 n This calculates 2^3 = 8 n It does this by calling expt, which computes an exponent. 16

17 Data Mode > '(expt 2 3) (EXPT 2 3) The single quote tells Lisp to treat the subsequent form as a chunk of data simply a list of items. > (quote (expt 2 3)) (EXPT 2 3) > '(1 2 3) (1 2 3) > ''(1 2 3) '(1 2 3) 17

18 But (Why? Read the error message) > ( 1 2 3) *** - EVAL: 1 is not a function name; try using a symbol instead The following restarts are available: USE-VALUE :R1 Input a value to be used instead. ABORT :R2 Abort debug loop ABORT :R3 Abort debug loop ABORT :R4 Abort debug loop ABORT :R5 Abort main loop Predicates 18

19 Numerical predicates (> 5 4 3) T (> 5 4 6) NIL (<= 3 2) NIL (= 1 2) NIL (= 1 1 1) T >(zerop 0) T >(integerp 5) T n > (eq )??? 19

20 n The eq function is the simplest of all the Lisp comparison functions, and it s also very fast. n It doesn t really work for comparing items besides symbols n The eql command is similar to the eq command, but unlike eq, it also handles comparisons of numbers and characters n The equalp command is essentially the same as the equal command, except that it can handle some difficult comparison cases with a bit of extra sophisti- cation 20

21 Atoms n Every Lisp object is either an atom or a list Lists in Lisp n A cons cell looks like this: n We create the list '(1 2 3) 21

22 Lists Dot notation 22

23 The cons Function link any two pieces of data >(cons 'chicken 'cat) (CHICKEN. CAT) > (cons 'chicken 'nil) (CHICKEN) > (cons 'chicken ()) (CHICKEN) > (cons 'beef (cons 'chicken nil)) (BEEF CHICKEN) > (cons 'beef (cons 'chicken nil)) (BEEF CHICKEN) >(cons 'pork '(beef)) (PORK BEEF) > (cons 'pork '(beef chicken)) (PORK BEEF CHICKEN) 23

24 The car and cdr Functions > (car '(pork beef chicken)) PORK > (cdr '(pork beef chicken)) (BEEF CHICKEN) > (cdr '(pork beef chicken)) (BEEF CHICKEN) > (car '(beef chicken)) BEEF > (car (cdr '(pork beef chicken))) BEEF > (cadr '(pork beef chicken)) BEEF 24

25 Nested Lists n Lists can contain other lists. '(cat (duck bat) ant) >(car '((peas carrots tomatoes) (pork beef chicken))) (PEAS CARROTS TOMATOES) 25

26 if > (if (= (+ 1 2) 3) 'yup 'nope) YUP >(if (= (+ 1 2) 4) 'yup 'nope) NOPE >(if '(1) 'the-list-has-stuff-in-it 'the-list-is-empty) THE-LIST-HAS-STUFF-IN-IT >(if '() 'the-list-has-stuff-in-it 'the-list-is-empty) THE-LIST-IS-EMPTY 26

27 > (if (oddp 5) 'odd-number 'even-number) ODD-NUMBER > (if (oddp 5) 'odd-number (/ 1 0)) ODD-NUMBER Why? Special form, executes only the true branch 27

28 Defining Global Variables 28

29 Local Variables Editor 29

31 31

### Lecture Notes on Lisp A Brief Introduction

Why Lisp? Lecture Notes on Lisp A Brief Introduction Because it s the most widely used AI programming language Because Prof Peng likes using it Because it s good for writing production software (Graham

### Functional 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

### Introduction to Lisp

Last update: February 16, 2010 Introduction to Lisp Dana Nau Dana Nau 1 Outline I assume you know enough about computer languages that you can learn new ones quickly, so I ll go pretty fast If I go too

### SCHEME 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,

### Allegro CL Certification Program

Allegro CL Certification Program Lisp Programming Series Level I Presented by 1 About David Margolies Manager, Documentation, Franz Inc Been working with Lisp since 1984 dm@franz.com 2 About Franz Inc.

### Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives

CS 6A Scheme Fall 207 Discussion 7: October 25, 207 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

### Symbolic Programming. Dr. Zoran Duric () Symbolic Programming 1/ 89 August 28, / 89

Symbolic Programming Symbols: +, -, 1, 2 etc. Symbolic expressions: (+ 1 2), (+ (* 3 4) 2) Symbolic programs are programs that manipulate symbolic expressions. Symbolic manipulation: you do it all the

### Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions

### Fundamentals of Artificial Intelligence COMP221: Functional Programming in Scheme (and LISP)

Fundamentals of Artificial Intelligence COMP221: Functional Programming in Scheme (and LISP) Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology

### Scheme: 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

### CS 480. Lisp J. Kosecka George Mason University. Lisp Slides

CS 480 Lisp J. Kosecka George Mason University Lisp Slides Symbolic Programming Symbols: +, -, 1, 2 etc. Symbolic expressions: (+ 1 2), (+ (* 3 4) 2) Symbolic programs are programs that manipulate symbolic

### Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003

Principles of Programming Languages Topic: Functional Programming Professor L. Thorne McCarty Spring 2003 CS 314, LS, LTM: Functional Programming 1 Scheme A program is an expression to be evaluated (in

### Announcement. Overview. LISP: A Quick Overview. Outline of Writing and Running Lisp.

Overview Announcement Announcement Lisp Basics CMUCL to be available on sun.cs. You may use GNU Common List (GCL http://www.gnu.org/software/gcl/ which is available on most Linux platforms. There is also

### Introduction to Artificial Intelligence CISC-481/681 Program 1: Simple Lisp Programs

CISC-481/681 Program 1: Simple Lisp Programs 1 Introduction to Artificial Intelligence CISC-481/681 Program 1: Simple Lisp Programs Reading: Handouts Summarizing Common Lisp Functions Paul Graham s ANSI

### SOFTWARE ARCHITECTURE 6. LISP

1 SOFTWARE ARCHITECTURE 6. LISP Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ 2 Compiler vs Interpreter Compiler Translate programs into machine languages Compilers are

### 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

### Fifth Generation CS 4100 LISP. What do we need? Example LISP Program 11/13/13. Chapter 9: List Processing: LISP. Central Idea: Function Application

Fifth Generation CS 4100 LISP From Principles of Programming Languages: Design, Evaluation, and Implementation (Third Edition, by Bruce J. MacLennan, Chapters 9, 10, 11, and based on slides by Istvan Jonyer

### The Design and Implementation of a Modern Lisp. Dialect

The Design and Implementation of a Modern Lisp Dialect Sam Davis Nicholas Alexander January 26, 2006 Abstract Lisp, invented in 1958 by John McCarthy, revolutionized how programs could be written and expressed.

### Project 2: Scheme Interpreter

Project 2: Scheme Interpreter CSC 4101, Fall 2017 Due: 12 November 2017 For this project, you will implement a simple Scheme interpreter in C++ or Java. Your interpreter should be able to handle the same

### Racket. CSE341: Programming Languages Lecture 14 Introduction to Racket. Getting started. Racket vs. Scheme. Example.

Racket Next 2+ weeks will use the Racket language (not ML) and the DrRacket programming environment (not emacs) Installation / basic usage instructions on course website CSE34: Programming Languages Lecture

### Common Lisp. Blake McBride

Contents Common Lisp Blake McBride (blake@mcbride.name) 1 Data Types 2 2 Numeric Hierarchy 3 3 Comments 3 4 List Operations 4 5 Evaluation and Quotes 5 6 String Operations 5 7 Predicates 6 8 Math Predicates

### CIS4/681 { Articial Intelligence 2 > (insert-sort '( )) ( ) 2 More Complicated Recursion So far everything we have dened requires

1 A couple of Functions 1 Let's take another example of a simple lisp function { one that does insertion sort. Let us assume that this sort function takes as input a list of numbers and sorts them in ascending

### Recursive Functions of Symbolic Expressions and Their Application, Part I

Recursive Functions of Symbolic Expressions and Their Application, Part I JOHN MCCARTHY Review: Amit Kirschenbaum Seminar in Programming Languages Recursive Functions of Symbolic Expressions and Their

### Lecture #2 Kenneth W. Flynn RPI CS

Outline Programming in Lisp Lecture #2 Kenneth W. Flynn RPI CS Items from last time Recursion, briefly How to run Lisp I/O, Variables and other miscellany Lists Arrays Other data structures Jin Li lij3@rpi.edu

### Scheme as implemented by Racket

Scheme as implemented by Racket (Simple view:) Racket is a version of Scheme. (Full view:) Racket is a platform for implementing and using many languages, and Scheme is one of those that come out of the

### A Brief Introduction to Scheme (II)

A Brief Introduction to Scheme (II) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Lists Scheme II p.1/29 Lists Aggregate data

### A Quick Introduction to Common Lisp

CSC 244/444 Notes last updated ug. 30, 2016 Quick Introduction to Common Lisp Lisp is a functional language well-suited to symbolic I, based on the λ-calculus and with list structures as a very flexible

### Organization of Programming Languages CS3200/5200N. Lecture 11

Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages

### Scheme: Strings Scheme: I/O

Scheme: Strings Scheme: I/O CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Wednesday, April 5, 2017 Glenn G. Chappell Department of Computer Science University of

### Meet the Macro. a quick introduction to Lisp macros. Patrick Stein / TC Lisp Users Group /

Meet the Macro a quick introduction to Lisp macros Patrick Stein / TC Lisp Users Group / 2009-07-14 Attack Plan Some other things called macros First look at Lisp macros More advanced macros Uh-oh, my

### Architecture of LISP Machines. Kshitij Sudan March 6, 2008

Architecture of LISP Machines Kshitij Sudan March 6, 2008 A Short History Lesson Alonzo Church and Stephen Kleene (1930) λ Calculus ( to cleanly define "computable functions" ) John McCarthy (late 60 s)

### (defmacro while (condition &body body) `(iterate loop () (if,condition (loop)))))

; PARCIL - A Parser for C syntax In Lisp version 0.1a copyright (c) 1992 by Erann Gat, all rights reserved This program is free software; you can redistribute it and/or modify it under the terms of the

### A LISP Interpreter in ML

UNIVERSITY OF OSLO Department of Informatics A LISP Interpreter in ML Mandatory Assignment 1 INF3110 September 21, 2009 Contents 1 1 Introduction The purpose of this assignment is to write an interpreter,

### Building a system for symbolic differentiation

Computer Science 21b Structure and Interpretation of Computer Programs Building a system for symbolic differentiation Selectors, constructors and predicates: (constant? e) Is e a constant? (variable? e)

### Department of Computer and information Science Norwegian University of Science and Technology

Department of Computer and information Science Norwegian University of Science and Technology http://www.idi.ntnu.no/ A Crash Course in LISP MNFIT272 2002 Anders Kofod-Petersen anderpe@idi.ntnu.no Introduction

### STREAMS 10. Basics of Streams. Practice with Streams COMPUTER SCIENCE 61AS. 1. What is a stream? 2. How does memoization work?

STREAMS 10 COMPUTER SCIENCE 61AS Basics of Streams 1. What is a stream? 2. How does memoization work? 3. Is a cons-stream a special form? Practice with Streams 1. Define a procedure (ones) that, when run

### (Func&onal (Programming (in (Scheme)))) Jianguo Lu

(Func&onal (Programming (in (Scheme)))) Jianguo Lu 1 Programming paradigms Func&onal No assignment statement No side effect Use recursion Logic OOP AOP 2 What is func&onal programming It is NOT what you

### Quote of the Day. CS Functional Programming. Introductory Notes on Lisp/Clojure. Another Quote. What is Clojure? 1-4

Quote of the Day CS 326 - Functional Programming Introductory Notes on Lisp/Clojure Dr. Stephen P. Carl By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more

### Common LISP-Introduction

Common LISP-Introduction 1. The primary data structure in LISP is called the s-expression (symbolic expression). There are two basic types of s-expressions: atoms and lists. 2. The LISP language is normally

### CSc 520 Principles of Programming Languages. Examining Lists. Constructing Lists... 7: Scheme List Processing

Constructing Lists CSc 520 Principles of Programming Languages 7: Scheme List Processing Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona The most important

### CMSC 331 Final Exam Section 0201 December 18, 2000

CMSC 331 Final Exam Section 0201 December 18, 2000 Name: nswers Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points

### Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with

### Essentials of Programming Languages Language

Essentials of Programming Languages Language Version 6.90.0.26 April 20, 2018 The Essentials of Programming Languages language in DrRacket provides a subset of functions and syntactic forms of racket mostly

### MORE SCHEME. 1 What Would Scheme Print? COMPUTER SCIENCE MENTORS 61A. October 30 to November 3, Solution: Solutions begin on the following page.

MORE SCHEME COMPUTER SCIENCE MENTORS 61A October 30 to November 3, 2017 1 What Would Scheme Print? Solutions begin on the following page. 1. What will Scheme output? Draw box-and-pointer diagrams to help

### ALISP interpreter in Awk

ALISP interpreter in Awk Roger Rohrbach 1592 Union St., #94 San Francisco, CA 94123 January 3, 1989 ABSTRACT This note describes a simple interpreter for the LISP programming language, written in awk.

### A short note on short differentiation programs in lisp, and a comment on logarithmic differentiation

A short note on short differentiation programs in lisp, and a comment on logarithmic differentiation Richard Fateman University of California, Berkeley September, 1998 1 Lisp and differentiation By tradition

### An Introduction to Scheme

An Introduction to Scheme Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Stéphane Ducasse 1 Scheme Minimal Statically scoped Functional Imperative Stack manipulation Specification

### Warm-up and Memoization

CSE341 Spring 05 Due Wednesday, May 11 Assignment 4 Part I Warm-up and Memoization Warm-up As a warm-up, write the following Scheme functions: 1. Write the function foldl of the form (foldl func initial

### A Mechanical Proof of the Turing Completeness of Pure Lisp

A Mechanical Proof of the Turing Completeness of Pure Lisp Robert S. Boyer and J Strother Moore Technical Report #37 May 1983 Institute for Computing Science 2100 Main Building The University of Texas

### Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples

Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the

### Lisp: Lab Information. Donald F. Ross

Lisp: Lab Information Donald F. Ross General Model program source text stream What you need to write lexical analysis lexemes tokens syntax analysis is_id, is_number etc. + grammar rules + symbol table

### Structure and Interpretation of Computer Programs

CS 61A Fall 2016 Structure and Interpretation of Computer Programs Final INSTRUCTIONS You have 3 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator, except

### Debugging in LISP. trace causes a trace to be printed for a function when it is called

trace causes a trace to be printed for a function when it is called ;;; a function that works like reverse (defun rev (list) (cons (first (last list)) (rev (butlast list)))) USER: (trace rev) ; note trace

### Project 1: Scheme Pretty-Printer

Project 1: Scheme Pretty-Printer CSC 4101, Fall 2017 Due: 7 October 2017 For this programming assignment, you will implement a pretty-printer for a subset of Scheme in either C++ or Java. The code should

### Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind

### UNIT 6A Organizing Data: Lists. Last Two Weeks

UNIT 6A Organizing Data: Lists 1 Last Two Weeks Algorithms: Searching and sorting Problem solving technique: Recursion Asymptotic worst case analysis using the big O notation 2 1 This Week Observe: The

### Using Hashtables to Find the Generation Point of a Problematic Cons

Using Hashtables to Find the Generation Point of a Problematic Cons Often when you generate a piece of bad data, you don t see a failure until after the program makes a lot of progress. In this case, issuing

### How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

### Table of Contents. Appendix B Libraries Used by Roan Appendix D Building and Modifying Roan Iterating over hash-sets...

Roan Version 8.0.7 This is documentation of Roan, version 8.0.7. This documentation is copyright c 2015-2017 Donald F Morrison. Copying and distribution of this documentation, with or without modification,

### Allegro CL Certification Program

Allegro CL Certification Program Lisp Programming Series Level I Review David Margolies 1 Summary 1 A lisp session contains a large number of objects which is typically increased by user-created lisp objects

### Structure and Interpretation of Computer Programs

CS 6A Fall 206 Structure and Interpretation of Computer Programs Final Solutions INSTRUCTIONS You have hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,

### COMPUTER SCIENCE IN THE NEWS. CS61A Lecture 21 Scheme TODAY REVIEW: DISPATCH DICTIONARIES DISPATCH DICTIONARIES 7/27/2012

COMPUTER SCIENCE IN THE NEWS CS6A Lecture 2 Scheme Jom Magrotker UC Berkeley EECS July 24, 202 http://spectrum.ieee.org/tech talk/robotics/artificial intelligence/a texas hold em tournament for ais 2 TODAY

### Custom Specializers in Object-Oriented Lisp

Custom Cadence Design Systems Goldsmiths, University of London 23rd May 2008 Common : Skill: Unification of various dialects; Not dead yet. Common Skill Internal dialect from Cadence Design Systems; Extension

### SOME LISP HISTORY AND SOME PROGRAM LANGUAGE IDEAS John McCarthy, Stanford University Berlin, 2002 June 19

SOME LISP HISTORY AND SOME PROGRAM LANGUAGE IDEAS John McCarthy, Stanford University Berlin, 2002 June 19 I suppose I m here because of Lisp, although I hav involved in the Lisp community for a very long

### A brief survey of programming languages: motivation and design/ continued. Lecture 3. Even more, Algol, Cobol. Are they really different?

Life beyond Fortran (1959), Algol (1960), Lisp 1.5 (1960), Cobol (1961) A brief survey of programming languages: motivation and design/ continued Lecture 3 Significant languages, commercial and/or intellectual

### MIDTERM EXAMINATION - CS130 - Spring 2005

MIDTERM EAMINATION - CS130 - Spring 2005 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 231 + 25 extra credit This exam counts for 25%

### STREAMS 10. Basics of Streams. Practice with Streams COMPUTER SCIENCE 61AS. 1. What is a stream?

STREAMS 10 COMPUTER SCIENCE 61AS Basics of Streams 1. What is a stream? A stream is an element and a promise to evaluate the rest of the stream. Streams are a clever idea that allows one to use sequence

### Lisp History. Lisp and Prolog Background. Lisp Use. Lisp Availability

Lisp and Prolog Background Thank you to Prof. Roosen-Runge and Prof. Gotshalks for the slides that I will be using throughout the course. Lisp History Lisp - invented (about 1958) by the logician and AI

### VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer

### Chapter 8 :: Composite Types

Chapter 8 :: Composite Types Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter08_Composite_Types_4e - Tue November 21, 2017 Records (Structures) and Variants

### CS 842 Ben Cassell University of Waterloo

CS 842 Ben Cassell University of Waterloo Recursive Descent Re-Cap Top-down parser. Works down parse tree using the formal grammar. Built from mutually recursive procedures. Typically these procedures

### Working with recursion

Working with recursion Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). We can extend the idea of a self-referential definition to defining the natural numbers, which leads to the use of recursion in

### Learning the Binary System

Learning the Binary System www.brainlubeonline.com/counting_on_binary/ Formated to L A TEX: /25/22 Abstract This is a document on the base-2 abstract numerical system, or Binary system. This is a VERY

### CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal)

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) What is the Metacircular Evaluator? It is the best part

### 6.001, Spring Semester, 1998, Final Exam Your Name: 2 Question 1 (12 points): Each of the parts below should be treated as independent. For each part,

1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring Semester, 1998, Final Exam Your Name: Open

### A Lazy List Implementation in Squeak

A Lazy List Implementation in Squeak Takashi Yamamiya This material is based upon work supported in part by the National Science Foundation under Grant No. 0639876. Any opinions, findings, and conclusions

### Problems 3-1, 3.3, 3.4 and 3.5 in Chapter 3 of Winston and Horn's LISP (see Below)

Homework Solutions: Problem Set Homework 2 Due uesday September 8, 2015 in class Be sure to follow the guidelines for Programming Assignments. Since these problems are simple, you may skip the Statement

### low and not larger than high. 18 points

CSE 330 Test 1 (1 point) Spring 015 Multiple Choice. Write your answer to the LEFT of each problem. 3 points each 1. Lisp was invented at: A. IBM B. MIT C. Netscape D. Stanford. In C++, what operator is

### ADTS, GRAMMARS, PARSING, TREE TRAVERSALS

1 Pointers to material ADS, GRAMMARS, PARSING, R RAVRSALS Lecture 13 CS110 all 016 Parse trees: text, section 3.36 Definition of Java Language, sometimes useful: docs.oracle.com/javase/specs/jls/se8/html/index.html

### hp calculators HP 50g Algebraic and RPN Operating Modes Calculation Modes A simple example - the area of a piece of carpet Setting the mode

Calculation Modes A simple example - the area of a piece of carpet Setting the mode Algebraic and RPN modes and the stack The command line Example a more complicated expression Example which stepladder?

### Scheme Quick Reference

Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries

### Topic 4 Expressions and variables

Topic 4 Expressions and variables "Once a person has understood the way variables are used in programming, he has understood the quintessence of programming." -Professor Edsger W. Dijkstra Based on slides

### Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

### CS664 Compiler Theory and Design LIU 1 of 16 ANTLR. Christopher League* 17 February Figure 1: ANTLR plugin installer

CS664 Compiler Theory and Design LIU 1 of 16 ANTLR Christopher League* 17 February 2016 ANTLR is a parser generator. There are other similar tools, such as yacc, flex, bison, etc. We ll be using ANTLR

### Parsing INI Files in Lisp

Parsing INI Files in Lisp Gene Michael Stover created Sunday, 2005 February 20 updated Sunday, 2005 February 20 Copyright c 2005 Gene Michael Stover. All rights reserved. Permission to copy, store, & view

### The PSL Users Manual

The PSL Users Manual Version 4.2 by Herbert Melenk and Winfried Neun Konrad Zuse Zentrum für Informationstechnik Berlin Division of Symbolic Computing Takustrasse 7 D 14195 Berlin-Dahlem URL: http://www.zib.de

### 2. Reasons for implementing clos-unit

A CLOS Implementation of the JUnit Testing Framework Architecture: A Case Study Sandro Pedrazzini Canoo Engineering AG sandro.pedrazzini@canoo.com Abstract There are different reasons why you would like

### Project 4 Due 11:59:59pm Thu, May 10, 2012

Project 4 Due 11:59:59pm Thu, May 10, 2012 Updates Apr 30. Moved print() method from Object to String. Apr 27. Added a missing case to assembler.ml/build constants to handle constant arguments to Cmp.

### JME Language Reference Manual

JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827

### Computer circles. Introduction. What s the problem? The story above makes as much sense if your English ancestors had moved to a remote village:

Computer circles Thursday 26 February 6pm Harold Thimbleby, Gresham Professor of Geometry Computer languages let us tell computers what to do. And we use computer languages to tell computers how to understand

### 19 Machine Learning in Lisp

19 Machine Learning in Lisp Chapter Objectives Chapter Contents ID3 algorithm and inducing decision trees from lists of examples. A basic Lisp implementation of ID3 Demonstration on a simple credit assessment

### Speaker Name: Bill Kramer. Course: CP33-2 A Visual LISP Wizard's Intro to Object Magic. Course Description

Speaker Name: Bill Kramer Course: CP33-2 A Visual LISP Wizard's Intro to Object Magic Course Description This course introduces the use of objects in Visual LISP and demonstrates how they can be created

### ADTS, GRAMMARS, PARSING, TREE TRAVERSALS

1 Prelim 1 2 Where: Kennedy Auditorium When: A-Lib: 5:30-7 Lie-Z: 7:30-9 (unless we explicitly notified you otherwise) ADS, GRAMMARS, PARSING, R RAVRSALS Lecture 13 CS2110 Spring 2016 Pointers to material

### // The next 4 functions return true on success, false on failure

Stacks and Queues Queues and stacks are two special list types of particular importance. They can be implemented using any list implementation, but arrays are a more practical solution for these structures

### Following the Grammar

Following the Grammar Gary T. Leavens TR #05-02a February 2005, Revised January 2006 Keywords: Recursion, programming recursive procedures, recursion pattern, inductive definition, BNF grammar, Kleene

### Interpreters and Tail Calls Fall 2017 Discussion 8: November 1, 2017 Solutions. 1 Calculator. calc> (+ 2 2) 4

CS 61A Interpreters and Tail Calls Fall 2017 Discussion 8: November 1, 2017 Solutions 1 Calculator We are beginning to dive into the realm of interpreting computer programs that is, writing programs that

### Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions:

Matrices A Matrix is an array of numbers: We talk about one matrix, or several matrices. There are many things we can do with them... Adding A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: