TES3111 Oct 2001 Data Structures S-Expression - Symbolic expression. It can be an Atom, a List or a collection of S- Expression enclosed by (…) Atom -

Slides:



Advertisements
Similar presentations
1 Programming Languages and Paradigms Lisp Programming.
Advertisements

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 Programming. LISP – simple and powerful mid-1950’s by John McCarthy at M.I.T. “ LIS t P rocessing language” Artificial Intelligence programs LISP.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
Introduction to Artificial Intelligence Lisp Ruth Bergman Fall 2002.
Lisp. Versions of LISP Lisp is an old language with many variants –LISP is an acronym for List Processing language Lisp is alive and well today Most modern.
CS 330 Programming Languages 11 / 20 / 2007 Instructor: Michael Eckmann.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
Introductory Lisp Programming Lecture # 2 Main Topics –Basic Lisp data types –Lisp primitives –Details of list handling Cons cells (boxes) & their representation.
Symbolic Expressions (S Expressions) Syntax: Opening and Closing parenthesis having elements in between. List represented in LISP: (A B2 C3 Shahid) (A.
The Fundamentals of C++ Basic programming elements and concepts JPC and JWD © 2002 McGraw-Hill, Inc.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
TES3111 October 2001 Artificial Intelligence LISP.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
JavaScript, Third Edition
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
LISP A brief overview. Lisp stands for “LISt Process” –Invented by John McCarthy (1958) –Simple data structure (atoms and lists) –Heavy use of recursion.
COMP 205 – Week 11 Dr. Chunbo Chu. Intro Lisp stands for “LISt Process” Invented by John McCarthy (1958) Simple data structure (atoms and lists) Heavy.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main.
LISP 1.5 and beyond A very quick tour. Data Atoms (symbols) including numbers – All types of numbers including Roman! (well, in the early days) – Syntactically.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Digital Electronics Data Structures LISP
Computer Science Department Data Structure & Algorithms Problem Solving with Stack.
2440: 211 Interactive Web Programming Expressions & Operators.
CSE S. Tanimoto Lisp Lisp S-Expressions: ATOMs Every Lisp object is either an ATOM or a CONS Symbols and numbers are kinds of atoms: X, APPLE,
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
TUTORIAL 1 CSCI3230 ( First Term) By Tony YI 1.
Introduction to Scheme Lectures on The Scheme Programming Language, 2 nd Ed. R. Kent Dybvig.
Overview of the Haskell 98 Programming Language
Programming in Lisp; Instructor: Alok Mehta Programming in Lisp Introduction to Lisp.
LISP Data Types Functional Programming Academic Year Alessandro Cimatti
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 9, 2005 Lecture Number: 6.
1 Comments Allow prose or commentary to be included in program Importance Programs are read far more often than they are written Programs need to be understood.
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
CS 330 Programming Languages 11 / 15 / 2007 Instructor: Michael Eckmann.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
C BASICS QUIZ (DATA TYPES & OPERATORS). C language has been developed by (1) Ken Thompson (2) Dennis Ritchie (3) Peter Norton (4) Martin Richards.
CSE S. Tanimoto Lisps's Basic Functionality 1 LISP: Basic Functionality S-expressions Conses Lists Predicates Evaluation and quoting Conditional.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving data LIFO (Last In First Out) structure.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Expressions and Data Types Professor Robin Burke.
CS 152: Programming Language Paradigms February 12 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
Lisp S-Expressions: ATOMs
A I (Artificial Intelligence)
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
PART II STACK APPLICATIONS
Introduction to C++ Programming
Scheme: Basic Functionality
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Lisp: Representation of Data
The Data Element.
LISP: Basic Functionality
Modern Programming Languages Lecture 18 Fakhar Lodhi
LISP: Basic Functionality
The Data Element.
LISP: Basic Functionality
Lisp.
CSE 3302 Programming Languages
Lisp: Representation of Data
Review of Java Fundamentals
The Fundamentals of C++
Presentation transcript:

TES3111 Oct 2001 Data Structures S-Expression - Symbolic expression. It can be an Atom, a List or a collection of S- Expression enclosed by (…) Atom - String of characters beginning with a letter, digit. Eg: Artificial, intelligence, etc.

TES3111 Oct 2001 Symbols & Lists A symbol is just a string of characters, made up of letters, digits and hyphens. Examples of symbols: jack, jill, what-is-that … etc. Lists consists of zero or more elements enclosed in parenthesis. It looks like this: ‘(element1 element2 …. Elementn)

TES3111 Oct 2001 Symbols and Lists Caution! - Lists must be preceded by a single quote ‘. Otherwise Lisp will evalute the whole expression as a function invocation. Examples of lists: ‘(what day “is today”) ‘(this (is a) nested list) To construct a list, do as use the list function as follows: (list ‘(a b c) (* 2 3 5)) An empty list is represented using () or nil.

TES3111 Oct 2001 Some Lisp Functions (setq x 5) ; assign the value 5 to x (let ((x 100) x) ; temporarily bind x to 100 (* a 9) Note that the semi-colon is use to insert comments. It is not the end of statement indicator as in other languages.

TES3111 Oct 2001 Boolean values True is represented as t and False is represented as nil. Examples of conditionals: (if t “Hello” “Wrong”) (if nil ) (if 1 2 3)

TES3111 Oct 2001 Keywords Keywords are self evaluating symbols. We have already encountered 2 of this kind - t and nil. Any symbols that begins with a colon is a keyword. Examples: :lisp-name-space :what-is-lisp

TES3111 Oct 2001 Numbers Lisp provides 4 types of numbers: –Integers: 12, 9, -12 –Rational numbers: 12/87, 987/10 –Real numbers: 3.142, , e-20 –Complex numbers in the form of #c(r i). Where r is the real part and i is the imaginary part. Examples: #c(1.65, 0.6)

TES3111 Oct 2001 Conversion & Extractions There are functions for converting and extracting components of the 4 kind of numbers. (float 23) ; convert integer to float (truncate ) ; (floor ) (ceiling ) (round )

TES3111 Oct 2001 Arithmetic Please be reminded that Lisp uses the prefix notation for function invocation. x - y - z, in Lisp this is (- x y z) (a * b) + (c*d), in Lisp this is (+ (* a b) (* c d)) (/ 24 7) ( ) Be careful of how you nest the operators.

TES3111 Oct 2001 Conses Try these out: (CAR ‘(a b c)) (CAR (CAR ‘(a b c)) (CDR ‘(a b c)) (CAR (CDR ‘(a b c)) What do these 2 functions do ? A cons is a 2-field record made up of car and cdr. (cons 23 24) (cons (cons 1 2) 3) (car (cons 9 10)) (cdr (cons 10 9))

TES3111 Oct 2001 Using lists as stacks How? By storing a list in a variable and using 2 functions: push and pop. (setq a nil) ; start with an empty stack (push 1 a) (push 2 a) (pop a)