# 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

8 n Conrad Barski Conrad Barski, M.D. 8

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

30 To load / compile n (load <nome-ficheiro>) n (load projecto.lisp ) n (compile-file "projecto") n (load "projecto") 30

31 31

### FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE,

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE, 2011 Jan Janoušek MI-FLP Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti L I S P - Introduction L I S P

### 11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

Functional programming FP Foundations, Scheme (2 In Text: Chapter 15 LISP: John McCarthy 1958 MIT List Processing => Symbolic Manipulation First functional programming language Every version after the

### Common LISP Tutorial 1 (Basic)

Common LISP Tutorial 1 (Basic) CLISP Download https://sourceforge.net/projects/clisp/ IPPL Course Materials (UST sir only) Download https://silp.iiita.ac.in/wordpress/?page_id=494 Introduction Lisp (1958)

### INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Common Lisp Fundamentals Stephan Oepen & Murhaf Fares Language Technology Group (LTG) August 30, 2017 Last Week: What is

### SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

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

### Modern Programming Languages. Lecture LISP Programming Language An Introduction

Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation

### Artificial Intelligence Programming

Artificial Intelligence Programming Rob St. Amant Department of Computer Science North Carolina State University Lisp basics NC State University 2 / 99 Why Lisp? Some recent Lisp success stories include

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

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

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

### Imperative, OO and Functional Languages A C program is

Imperative, OO and Functional Languages A C program is a web of assignment statements, interconnected by control constructs which describe the time sequence in which they are to be executed. In Java programming,

### 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 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives

CS 6A Scheme Fall 208 Discussion 8: October 24, 208 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

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

### Topic III. LISP : functions, recursion, and lists References: Chapter 3 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

Topic III LISP : functions, recursion, and lists References: Chapter 3 of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapters 5( 4.5) and 13( 1) of Programming languages: Design and

### Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

### Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

CS 61A Scheme Spring 2018 Discussion 7: March 21, 2018 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

### Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

CS 61A Scheme Spring 2018 Discussion 7: March 21, 2018 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

### CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages Lecture 16: Functional Programming Zheng (Eddy Zhang Rutgers University April 2, 2018 Review: Computation Paradigms Functional: Composition of operations on data.

### Documentation for LISP in BASIC

Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have

### Introduction to LISP. York University Department of Computer Science and Engineering. York University- CSE V.

Introduction to LISP York University Department of Computer Science and Engineering York University- CSE 3401- V. Movahedi 11_LISP 1 Introduction to LISP Evaluation and arguments S- expressions Lists Numbers

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

### Scheme: Expressions & Procedures

Scheme: Expressions & Procedures CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, March 31, 2017 Glenn G. Chappell Department of Computer Science University

### Gene Kim 9/9/2016 CSC 2/444 Lisp Tutorial

Gene Kim 9/9/2016 CSC 2/444 Lisp Tutorial About this Document This document was written to accompany an in-person Lisp tutorial. Therefore, the information on this document alone is not likely to be sufficient

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

### Introduction to lambda calculus Part 3

Introduction to lambda calculus Part 3 Antti-Juhani Kaijanaho 2017-01-27... 1 Untyped lambda calculus... 2 Typed lambda calculi In an untyped lambda calculus extended with integers, it is required that

### Functional Programming

Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used

### LISP. York University CSE 3401 Vida Movahedi. York University CSE 3401 V. Movahedi 11_LISP

Introduction to LISP York University CSE 3401 Vida Movahedi York University CSE 3401 V. Movahedi 11_LISP 1 Overview Introduction to LISP Evaluation and arguments S expressions Lists Numbers Symbols setq,

### SCHEME The Scheme Interpreter. 2 Primitives COMPUTER SCIENCE 61A. October 29th, 2012

SCHEME COMPUTER SCIENCE 6A October 29th, 202 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, we will eventually

### Introduction to Functional Programming and basic Lisp

Introduction to Functional Programming and basic Lisp Based on Slides by Yves Lespérance & Peter Roosen-Runge 1 Functional vs Declarative Programming declarative programming uses logical statements to

### Functional Programming. Pure Functional Programming

Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

### Functional Programming. Big Picture. Design of Programming Languages

Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics

### CSCI337 Organisation of Programming Languages LISP

Organisation of Programming Languages LISP Getting Started Starting Common Lisp \$ clisp i i i i i i i ooooo o ooooooo ooooo ooooo I I I I I I I 8 8 8 8 8 o 8 8 I \ `+' / I 8 8 8 8 8 8 \ `-+-' / 8 8 8 ooooo

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

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

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

### LISP. Everything in a computer is a string of binary digits, ones and zeros, which everyone calls bits.

LISP Everything in a computer is a string of binary digits, ones and zeros, which everyone calls bits. From one perspective, sequences of bits can be interpreted as a code for ordinary decimal digits,

### A Small Interpreted Language

A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

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

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

### Symbolic Computation and Common Lisp

Symbolic Computation and Common Lisp Dr. Neil T. Dantam CSCI-56, Colorado School of Mines Fall 28 Dantam (Mines CSCI-56) Lisp Fall 28 / 92 Why? Symbolic Computing: Much of this course deals with processing

### SOFTWARE ARCHITECTURE 6. LISP.

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

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

### 15 Unification and Embedded Languages in Lisp

15 Unification and Embedded Languages in Lisp Chapter Objectives Chapter Contents Pattern matching in Lisp: Database examples Full unification as required for Predicate Calculus problem solving Needed

### by the evening of Tuesday, Feb 6

Homework 1 Due 14 February Handout 6 CSCI 334: Spring 2018 Notes This homework has three types of problems: Self Check: You are strongly encouraged to think about and work through these questions, and

### Lisp. Versions of LISP

Lisp Versions of LISP Lisp is an old language with many variants Lisp is alive and well today Most modern versions are based on Common Lisp LispWorks is based on Common Lisp Scheme is one of the major

### Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Scheme Tutorial Introduction Scheme is an imperative language with a functional core. The functional core is based on the lambda calculus. In this chapter only the functional core and some simple I/O is

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

### Homework 1. Reading. Problems. Handout 3 CSCI 334: Spring, 2012

Homework 1 Due 14 February Handout 3 CSCI 334: Spring, 2012 Reading 1. (Required) Mitchell, Chapter 3. 2. (As Needed) The Lisp Tutorial from the Links web page, as needed for the programming questions.

### Functional programming with Common Lisp

Functional programming with Common Lisp Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 81 Expressions and functions

### Principles of Programming Languages COMP251: Functional Programming in Scheme (and LISP)

Principles of Programming Languages COMP251: Functional Programming in Scheme (and LISP) Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology

### FP Foundations, Scheme

FP Foundations, Scheme In Text: Chapter 15 1 Functional Programming -- Prelude We have been discussing imperative languages C/C++, Java, Fortran, Pascal etc. are imperative languages Imperative languages

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

### Introduction 2 Lisp Part III

Introduction 2 Lisp Part III Andreas Wichert LEIC-T (Página da cadeira: Fenix) (I) Home Work (II) Data Types and Generic Programming (III) Lisp is Science (IV) Lisp Macros (V) More about Common Lisp an

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

### Look at the outermost list first, evaluate each of its arguments, and use the results as arguments to the outermost operator.

LISP NOTES #1 LISP Acronymed from List Processing, or from Lots of Irritating Silly Parentheses ;) It was developed by John MacCarthy and his group in late 1950s. Starting LISP screen shortcut or by command

### FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 3. LISP: ZÁKLADNÍ FUNKCE, POUŽÍVÁNÍ REKURZE,

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 3. LISP: ZÁKLADNÍ FUNKCE, POUŽÍVÁNÍ REKURZE, 2011 Jan Janoušek MI-FLP Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti Comments in Lisp ; comments

### Homework 1. Notes. What To Turn In. Unix Accounts. Reading. Handout 3 CSCI 334: Spring, 2017

Homework 1 Due 14 February Handout 3 CSCI 334: Spring, 2017 Notes This homework has three types of problems: Self Check: You are strongly encouraged to think about and work through these questions, but

### ;; definition of function, fun, that adds 7 to the input (define fun (lambda (x) (+ x 7)))

Homework 1 Due 13 September Handout 2 CSC 131: Fall, 2006 6 September Reading 1. Read Mitchell, Chapter 3. 2. The Scheme Tutorial and the Scheme Quick Reference from the Links web page, as needed for the

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

### 6.001: Structure and Interpretation of Computer Programs

6.001: Structure and Interpretation of Computer Programs Symbols Quotation Relevant details of the reader Example of using symbols Alists Differentiation Data Types in Lisp/Scheme Conventional Numbers

### Functional programming in LISP

Programming Languages Week 4 Functional programming in LISP College of Information Science and Engineering Ritsumeikan University review of part 3 enumeration of dictionaries you receive a sequence of

### Functional Programming with Common Lisp

Functional Programming with Common Lisp Kamen Tomov ktomov@hotmail.com July 03, 2015 Table of Contents What is This About? Functional Programming Specifics Is Lisp a Functional Language? Lisp Says Hi Functional

### Symbolic Reasoning. Dr. Neil T. Dantam. Spring CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Symbolic Reasoning Spring / 86

Symbolic Reasoning Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Spring 2019 Dantam (Mines CSCI-561) Symbolic Reasoning Spring 2019 1 / 86 Introduction Definition: Symbolic Reasoning Inference

### COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

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

### Robot Programming with Lisp

2. Imperative Programming Institute for Artificial University of Bremen Lisp the Language LISP LISt Processing language 2 Lisp the Language LISP LISt Processing language (LISP Lots of Irritating Superfluous

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

### Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.

The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction! Numeric operators, REPL, quotes, functions, conditionals! Function examples, helper

### INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. More Common Lisp

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing More Common Lisp Stephan Oepen & Murhaf Fares Language Technology Group (LTG) September 6, 2017 Agenda 2 Previously Common

### Lecture #24: Programming Languages and Programs

Lecture #24: Programming Languages and Programs A programming language is a notation for describing computations or processes. These range from low-level notations, such as machine language or simple hardware

### Lists in Lisp and Scheme

Lists in Lisp and Scheme a Lists in Lisp and Scheme Lists are Lisp s fundamental data structures, but there are others Arrays, characters, strings, etc. Common Lisp has moved on from being merely a LISt

### COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

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

### INTERPRETATION AND SCHEME LISTS 12

INTERPRETATION AND SCHEME LISTS 12 COMPUTER SCIENCE 61A July 26, 2012 1 Calculator Language We are beginning to dive into the realm of interpreting computer programs. To do so, we will examine a few new

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

### INF4820. Common Lisp: Closures and Macros

INF4820 Common Lisp: Closures and Macros Erik Velldal University of Oslo Oct. 19, 2010 Erik Velldal INF4820 1 / 22 Topics for Today More Common Lisp A quick reminder: Scope, binding and shadowing Closures

### CS 275 Name Final Exam Solutions December 16, 2016

CS 275 Name Final Exam Solutions December 16, 2016 You may assume that atom? is a primitive procedure; you don t need to define it. Other helper functions that aren t a standard part of Scheme you need

### Functional Programming Lecture 1: Introduction

Functional Programming Lecture 1: Introduction Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz Acknowledgements

### INTERPRETATION AND SCHEME LISTS 12

INTERPRETATION AND SCHEME LISTS 12 COMPUTER SCIENCE 61A July 26, 2012 1 Calculator Language We are beginning to dive into the realm of interpreting computer programs. To do so, we will examine a few new

### LECTURE 16. Functional Programming

LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative

### Programming Languages

Programming Languages Tevfik Koşar Lecture - XIII March 2 nd, 2006 1 Roadmap Functional Languages Lambda Calculus Intro to Scheme Basics Functions Bindings Equality Testing Searching 2 1 Functional Languages

### Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Northeastern University March 22, 2012 Version: 58 Copyright c 2012 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

### A little bit of Lisp

B.Y. Choueiry 1 Instructor s notes #3 A little bit of Lisp Introduction to Artificial Intelligence CSCE 476-876, Fall 2018 www.cse.unl.edu/~choueiry/s18-476-876 Read LWH: Chapters 1, 2, 3, and 4. Every

### A little bit of Lisp

B.Y. Choueiry 1 Instructor s notes #3 A little bit of Lisp Introduction to Artificial Intelligence CSCE 476-876, Fall 2017 www.cse.unl.edu/~choueiry/f17-476-876 Read LWH: Chapters 1, 2, 3, and 4. Every

### Introduction to Scheme

How do you describe them Introduction to Scheme Gul Agha CS 421 Fall 2006 A language is described by specifying its syntax and semantics Syntax: The rules for writing programs. We will use Context Free

### Control in Sequential Languages

CS 242 2012 Control in Sequential Languages Reading: Chapter 8, Sections 8.1 8.3 (only) Section 7.3 of The Haskell 98 Report, Exception Handling in the I/O Monad, http://www.haskell.org/onlinelibrary/io-13.html

### CS A331 Programming Language Concepts

CS A331 Programming Language Concepts Lecture 10 Alternative Programming Languages (Functional LISP Declarative - PROLOG) March 24, 2014 Sam Siewert Functional PL Concepts Based on Lambda Calculus Output

### CS A331 Programming Language Concepts

CS A331 Programming Language Concepts Lecture 10 Alternative Programming Languages (Functional LISP Declarative - PROLOG) March 24, 2014 Sam Siewert Functional PL Concepts Based on Lambda Calculus Output

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

### Recursive Functions of Symbolic Expressions and Their Computation by Machine Part I

Recursive Functions of Symbolic Expressions and Their Computation by Machine Part I by John McCarthy Ik-Soon Kim Winter School 2005 Feb 18, 2005 Overview Interesting paper with By John Mitchell Interesting

### CSc 520 Principles of Programming Languages

CSc 520 Principles of Programming Languages 3: Scheme Introduction Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg [1]

### CSC 533: Programming Languages. Spring 2015

CSC 533: Programming Languages Spring 2015 Functional programming LISP & Scheme S-expressions: atoms, lists functional expressions, evaluation, define primitive functions: arithmetic, predicate, symbolic,