SlideShare una empresa de Scribd logo
1 de 25
Data Types in Lisp
Overview Numbers Characters Symbols Lists and conses Arrays Hash tables Functions Data structures
In Lisp, data type is possibly a set of lisp objects. The set of all objects is defined by the symbol t. The empty data type which contains no data objects, is defined by nil. A type called common encompasses all the data objects required by the Common Lisp Objects. The following categories of Common Lisp Objects are of particular interest: Numbers, characters, Symbols, Lists, arrays, structures, and functions. Lisp data types
Numbers Number data type includes all kinds of data numbers. Integers and ratios are of type Rational. Rational  numbers and floating point numbers are of type Real. Real  numbers and complex numbers are of type Number. Numbers of type Float may be used to approximate real numbers both rational and irrational. Integer data type is used to represent common  mathematical integers. In Common Lisp there is a range of integers that are represented  more efficiently than others; each integer is called a Fixnum. ( range: -2^n to 2^n-1, inclusive) An integer that is not a fixnum is called bignum. Integers may be noted in radices other than 10. The notation  #nnrddddd or #nnRddddd means the integer in radix-nn notation denoted by the digits dddd.
Numbers Numbers A ratio is the number representing the mathematical ratio of two integers. Integers and ratios collectively constitute the Rational. Rule of rational canonicalization: If any computation produces a result that is a ratio of two integers such that the denominator evenly divides the numerator, the result is immediately converted into the equivalent integer. Complex numbers( type Complex) are represented in Cartesian form, with a real part and an imaginary part, each of which is a non-complex number.  Complex numbers are denoted by #c followed by a list of real and imaginary parts. Ex: #c(5 -4), #c(0 1) etc.
Numbers Numbers A floating-point  number is a rationale number of the form s.f.b^(e-p) where s is the sign(+1 or -1), b is the base(integer greater than 1), p is the precision, f is the significand ( positive integer between b^(p-1) and b^p -1 inclusive), e is the exponent.  Recommended minimum Floating-point precision and Exponent Size.
Characters Characters are of data objects of type Character. There are 2 subtypes of interest :standard-char and string-char. A character object is denoted by writing #followed by the character itself. Ex: # The Common Lisp character set consists of a space character#pace and a new line character#ewline, and the following 94 non-blank printing characters.(standard characters) ! “ # $ % & ‘ ( ) + * , - . / 0 1 2 3 4 5 6 7 8 9 : ; <  > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ ‘ a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~
Characters Characters The following characters are called semi-standard charecters: #ackspace,  #ab,  #inefeed,  #age, #eturn, #ubout Every object of type character has three attributes: code( intended to distinguish between character printed glyphs and formatting functions for characters), bits( allows extra flags to be associated with a character.) and font(specifies the specification of the style of the glyphs) Any character whose bits and fonts are zero may be contained in strings. All such characters together constitute a subtype of characters  called string-char.
Symbols Every object of type symbol has a name called its print-name. Symbols have a component called the property-list or plist. A symbol is notated simply by writing its name, if its name is not empty. Ex: frobbboz, +$, /user/games/slider Other notating symbols are: + - * / @ $ % ^ & _  < > ~ . Writing an escape character( before any character causes the character to be treated itself as an ordinary character. Ex:  denotes character (        1 denotes +1
Lists and Cons A cons is a record structure containing two components called the car and the cdr. Conses are used primarily to represent Lists. A list is a chain of conses  linked by their cdr components and terminated by nil. The car components of the conses are called the elements of the lists. A list is notated by writing the elements of the list in order, separated by blank spaces and sorrounded by parenthesis. Ex: ( a b c). A dotted-list is one whose last  cons doesn't have a nil for its cdr., after the last element and before the parenthesis is written a dot and the cdr of the last cons. Ex: ( a b c. 4), ( a . d) etc.. In Lisp ( a b . ( c d)) means same as the (a b c d)
Arrays An array is an object with the components arranged according to a Cartesian co-ordinate system. The number of dimensions of an array is called its rank. An array element is specified by a sequence of elements.The length of the sequence must be equal to the rank of the array. One may refer to array elements using the function aref. Ex: (aref foo 2 1) refers to element (2,1) of the array.
Arrays Arrays Multi-dimensional arrays store their components in row-major order Internally the multidimensional array is stored as a one-dimensional array, with the multidimensional index sets ordered lexicographically, last index varying fastest. This is important in 2 situations: ,[object Object]
When accessing  very large arrays in virtual-memory implementation.A simple-array is one which is not displaced to another array, has no fill pointer, and is not to have its size adjusted dynamically after creation.
Arrays Arrays To create an array use the syntax: Make-array dimensions &key :element-type             :initial-element :initial-contents: adjustable:fill-pointer: displaced to: displaced-index-offset. Ex: (make array ‘(4 2 3) : initial contents                              ‘(((a b c) (1 2 3))                                ((d e f) (3 1 2))                                 ((g h i) (2 3 1))                                  ((j k l) (0 0 0))))
Vectors One dimensional array is called vectors in lisp and constitute the type Lisp. Vectors and Lisps are collectively considered to be sequences. A general vectors is notated by notating the components in order sorrounded by #( and ) Ex: #( a b c d ), #( ), #( 1 2 3 ) etc.
Structures Structures are instances of user-defined data types that have a fixed number of named components. Structures are declared using the defstruct  construct. The default notation for a structure is: #s(structure-name                   slot-name-1 slot-value-1                  slot-name-2 slot-value-2                  ……….) Where #s indicates structure syntax, structure name is the name(symbol) the structure type, each slot-name is the name of the component and each corresponding slot value is the representation of the lisp object in that slot.
Hash tables provide an efficient way of mapping any LIST object (a key) to an associate object. To work with hash tables CL provides the constructor function (make-hash-table) and the accessor function( get-hash). In order to look up a key and find the associated value, (use gethash) New entries are added to hash table using the setq and gethash functions. To remove an entry use remhash. Hash Tables
Hash Tables Ex: (setq a (make-hash-table))        (setf  (gethash ‘color a) ‘black)         (setq (gethash ‘name a) ‘fred) (Gethash ‘color a)black (gethash  ‘name a)fred (gethash ‘pointy a)nil
Hash Tables Hash table functions Syntax: make-hash-table &key :test :size :rehash-size :rehash-threshold :test attribute  determines how the attributes are compared, it must be one of the values( #’eq, #’eql, #’eql or one of the symbols(eq, eql, equal) :size attribute sets the initial size of the hash table. :rehash-size argument specifies how much to increase the size of the hash table when it becomes full. :rehash-threshold specifies how full the hash table can be before it must grow. Ex:  (make-hash-table: re-hash size 1.5                                     :size (* number-of-widgets 43))
Functions Functions are objects that can be invoked as procedures: These may take arguments and return values. A compiled function is a compiled-code object. A lambda-expression (a list whose car is the symbol lambda) may serve as a function.
Data structures CL operators for manipulating lists as data structures are used for: ,[object Object]
Accessing particular members of the list
Appending multiple lists together to make a new list
Extracting elements from the list to make a new list.Common lisp defines accessor function from first to tenth as a means of accessing the first ten elements of the list. Ex: (first ‘(a b c))A        (third ‘(a b c))C Use the function nth to access an element from the arbitrary list. Ex: (nth 0 ‘(a b c))A       (nth 1 ‘(a b c))B
Data structures Data structures To check if a particular object is lisp or  not,CL provides Listp function.It always returns either T or NIL Ex: (listp ‘(pontaic cadillac chevrolet))T       (listp 99)NIL The function Length is used to get the number of elements in List as an integers. Ex: (length ‘(pontaic cadillac chevrolet))3 The member function is used to determine if the particular item is a member of the particular list. Ex: (member ‘dallas ‘(boston san-fransisco portland))NIL (member ‘san-fransisco’(boston san-fransisco portland))SAN-FRANSISCO PORTLAND

Más contenido relacionado

La actualidad más candente

Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)Chirag Shetty
 
2 data types and operators in r
2 data types and operators in r2 data types and operators in r
2 data types and operators in rDr Nisha Arora
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear listsToniyaP1
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsRanel Padon
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programmingnmahi96
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data typesMohd Sajjad
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Bryan O'Sullivan
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expressionMegha V
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsingkunj desai
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in pythonJothi Thilaga P
 

La actualidad más candente (20)

Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
 
C programming
C programmingC programming
C programming
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
2 data types and operators in r
2 data types and operators in r2 data types and operators in r
2 data types and operators in r
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular Expressions
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
Python : Regular expressions
Python : Regular expressionsPython : Regular expressions
Python : Regular expressions
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Tut1
Tut1Tut1
Tut1
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 

Destacado

Поездка на IT-DUMP 2012
Поездка на IT-DUMP 2012Поездка на IT-DUMP 2012
Поездка на IT-DUMP 2012Alexey Zinoviev
 
Михаил Давыдов - JavaScript. Базовые знания
Михаил Давыдов - JavaScript. Базовые знанияМихаил Давыдов - JavaScript. Базовые знания
Михаил Давыдов - JavaScript. Базовые знанияYandex
 
гаметогенеза весна карчевска
гаметогенеза  весна карчевскагаметогенеза  весна карчевска
гаметогенеза весна карчевскаFesna
 
ADM Proxy Card
ADM Proxy CardADM Proxy Card
ADM Proxy Cardfinance6
 
Things I didn't know about Augmented Reality
Things I didn't know about Augmented RealityThings I didn't know about Augmented Reality
Things I didn't know about Augmented RealityAnish Shah
 
My favourite swimmer
My favourite swimmerMy favourite swimmer
My favourite swimmerprosvsports
 
Размножение и развитие рыб.
Размножение и развитие рыб.Размножение и развитие рыб.
Размножение и развитие рыб.NickEliot
 
세션 2. 최항섭 지식검색과 작은 지식의 힘
세션 2. 최항섭 지식검색과 작은 지식의 힘세션 2. 최항섭 지식검색과 작은 지식의 힘
세션 2. 최항섭 지식검색과 작은 지식의 힘gojipcap
 
Релизы? Регулярно по пятницам
 Релизы? Регулярно по пятницам Релизы? Регулярно по пятницам
Релизы? Регулярно по пятницамDevDay
 
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере Resharper
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере ResharperCodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере Resharper
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере ResharperCodeFest
 
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWares
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWaresRST2014_Taganrog_ExpandedGraphiteCompositeMaterialWares
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWaresRussianStartupTour
 
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14Sarrià de Ter en Xarxa. Càpsula 27. 21mar14
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14Roger Casero Gumbau
 
JEEConf-2013 Krivopustov
JEEConf-2013 KrivopustovJEEConf-2013 Krivopustov
JEEConf-2013 Krivopustovknstvk
 
Отчет Союза Атамекен по исполнению поручений Президиума
Отчет Союза Атамекен по исполнению поручений Президиума Отчет Союза Атамекен по исполнению поручений Президиума
Отчет Союза Атамекен по исполнению поручений Президиума НЭПК "СОЮЗ "АТАМЕКЕН"
 
Nonblack bullet 191
Nonblack bullet 191Nonblack bullet 191
Nonblack bullet 191ustwo
 

Destacado (20)

Социальные сети
Социальные сетиСоциальные сети
Социальные сети
 
Поездка на IT-DUMP 2012
Поездка на IT-DUMP 2012Поездка на IT-DUMP 2012
Поездка на IT-DUMP 2012
 
Михаил Давыдов - JavaScript. Базовые знания
Михаил Давыдов - JavaScript. Базовые знанияМихаил Давыдов - JavaScript. Базовые знания
Михаил Давыдов - JavaScript. Базовые знания
 
гаметогенеза весна карчевска
гаметогенеза  весна карчевскагаметогенеза  весна карчевска
гаметогенеза весна карчевска
 
ADM Proxy Card
ADM Proxy CardADM Proxy Card
ADM Proxy Card
 
Things I didn't know about Augmented Reality
Things I didn't know about Augmented RealityThings I didn't know about Augmented Reality
Things I didn't know about Augmented Reality
 
ActiveTalk
ActiveTalkActiveTalk
ActiveTalk
 
My favourite swimmer
My favourite swimmerMy favourite swimmer
My favourite swimmer
 
Размножение и развитие рыб.
Размножение и развитие рыб.Размножение и развитие рыб.
Размножение и развитие рыб.
 
세션 2. 최항섭 지식검색과 작은 지식의 힘
세션 2. 최항섭 지식검색과 작은 지식의 힘세션 2. 최항섭 지식검색과 작은 지식의 힘
세션 2. 최항섭 지식검색과 작은 지식의 힘
 
Clojure noir
Clojure noirClojure noir
Clojure noir
 
Aplicaciones Geologico-Mineras
Aplicaciones Geologico-MinerasAplicaciones Geologico-Mineras
Aplicaciones Geologico-Mineras
 
Что такое общество
Что такое обществоЧто такое общество
Что такое общество
 
Релизы? Регулярно по пятницам
 Релизы? Регулярно по пятницам Релизы? Регулярно по пятницам
Релизы? Регулярно по пятницам
 
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере Resharper
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере ResharperCodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере Resharper
CodeFest 2013. Скрыган К. — Оптимизация .Net приложений на примере Resharper
 
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWares
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWaresRST2014_Taganrog_ExpandedGraphiteCompositeMaterialWares
RST2014_Taganrog_ExpandedGraphiteCompositeMaterialWares
 
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14Sarrià de Ter en Xarxa. Càpsula 27. 21mar14
Sarrià de Ter en Xarxa. Càpsula 27. 21mar14
 
JEEConf-2013 Krivopustov
JEEConf-2013 KrivopustovJEEConf-2013 Krivopustov
JEEConf-2013 Krivopustov
 
Отчет Союза Атамекен по исполнению поручений Президиума
Отчет Союза Атамекен по исполнению поручений Президиума Отчет Союза Атамекен по исполнению поручений Президиума
Отчет Союза Атамекен по исполнению поручений Президиума
 
Nonblack bullet 191
Nonblack bullet 191Nonblack bullet 191
Nonblack bullet 191
 

Similar a LISP: Data types in lisp

LISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP Content
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And OutputLISP Content
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptxssuser8e50d8
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Stringsnikshaikh786
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxprakashvs7
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsMegha V
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language CHANDAN KUMAR
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashessana mateen
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its functionFrankie Jones
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) wahab khan
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in Rnaroranisha
 
Linear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdfLinear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdfssuser37b0e0
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARDTia Ricci
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Python data type
Python data typePython data type
Python data typeJaya Kumari
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashingchidabdu
 

Similar a LISP: Data types in lisp (20)

LISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP: Type specifiers in lisp
LISP: Type specifiers in lisp
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Strings
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
 
Variables In Php 1
Variables In Php 1Variables In Php 1
Variables In Php 1
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
Constants
ConstantsConstants
Constants
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its function
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
 
Linear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdfLinear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdf
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Python data type
Python data typePython data type
Python data type
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashing
 

Más de LISP Content

LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In LispLISP Content
 
LISP:Declarations In Lisp
LISP:Declarations In LispLISP:Declarations In Lisp
LISP:Declarations In LispLISP Content
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In LispLISP Content
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP Content
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In LispLISP Content
 
LISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP Content
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP Content
 
LISP: Program structure in lisp
LISP: Program structure in lispLISP: Program structure in lisp
LISP: Program structure in lispLISP Content
 
LISP: Predicates in lisp
LISP: Predicates in lispLISP: Predicates in lisp
LISP: Predicates in lispLISP Content
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lispLISP Content
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 

Más de LISP Content (11)

LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In Lisp
 
LISP:Declarations In Lisp
LISP:Declarations In LispLISP:Declarations In Lisp
LISP:Declarations In Lisp
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem Lisp
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In Lisp
 
LISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP: Symbols and packages in lisp
LISP: Symbols and packages in lisp
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
LISP: Program structure in lisp
LISP: Program structure in lispLISP: Program structure in lisp
LISP: Program structure in lisp
 
LISP: Predicates in lisp
LISP: Predicates in lispLISP: Predicates in lisp
LISP: Predicates in lisp
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

LISP: Data types in lisp

  • 2. Overview Numbers Characters Symbols Lists and conses Arrays Hash tables Functions Data structures
  • 3. In Lisp, data type is possibly a set of lisp objects. The set of all objects is defined by the symbol t. The empty data type which contains no data objects, is defined by nil. A type called common encompasses all the data objects required by the Common Lisp Objects. The following categories of Common Lisp Objects are of particular interest: Numbers, characters, Symbols, Lists, arrays, structures, and functions. Lisp data types
  • 4. Numbers Number data type includes all kinds of data numbers. Integers and ratios are of type Rational. Rational numbers and floating point numbers are of type Real. Real numbers and complex numbers are of type Number. Numbers of type Float may be used to approximate real numbers both rational and irrational. Integer data type is used to represent common mathematical integers. In Common Lisp there is a range of integers that are represented more efficiently than others; each integer is called a Fixnum. ( range: -2^n to 2^n-1, inclusive) An integer that is not a fixnum is called bignum. Integers may be noted in radices other than 10. The notation #nnrddddd or #nnRddddd means the integer in radix-nn notation denoted by the digits dddd.
  • 5. Numbers Numbers A ratio is the number representing the mathematical ratio of two integers. Integers and ratios collectively constitute the Rational. Rule of rational canonicalization: If any computation produces a result that is a ratio of two integers such that the denominator evenly divides the numerator, the result is immediately converted into the equivalent integer. Complex numbers( type Complex) are represented in Cartesian form, with a real part and an imaginary part, each of which is a non-complex number. Complex numbers are denoted by #c followed by a list of real and imaginary parts. Ex: #c(5 -4), #c(0 1) etc.
  • 6. Numbers Numbers A floating-point number is a rationale number of the form s.f.b^(e-p) where s is the sign(+1 or -1), b is the base(integer greater than 1), p is the precision, f is the significand ( positive integer between b^(p-1) and b^p -1 inclusive), e is the exponent. Recommended minimum Floating-point precision and Exponent Size.
  • 7. Characters Characters are of data objects of type Character. There are 2 subtypes of interest :standard-char and string-char. A character object is denoted by writing #followed by the character itself. Ex: # The Common Lisp character set consists of a space character#pace and a new line character#ewline, and the following 94 non-blank printing characters.(standard characters) ! “ # $ % & ‘ ( ) + * , - . / 0 1 2 3 4 5 6 7 8 9 : ; < > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ ‘ a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~
  • 8. Characters Characters The following characters are called semi-standard charecters: #ackspace, #ab, #inefeed, #age, #eturn, #ubout Every object of type character has three attributes: code( intended to distinguish between character printed glyphs and formatting functions for characters), bits( allows extra flags to be associated with a character.) and font(specifies the specification of the style of the glyphs) Any character whose bits and fonts are zero may be contained in strings. All such characters together constitute a subtype of characters called string-char.
  • 9. Symbols Every object of type symbol has a name called its print-name. Symbols have a component called the property-list or plist. A symbol is notated simply by writing its name, if its name is not empty. Ex: frobbboz, +$, /user/games/slider Other notating symbols are: + - * / @ $ % ^ & _ < > ~ . Writing an escape character( before any character causes the character to be treated itself as an ordinary character. Ex:  denotes character ( 1 denotes +1
  • 10. Lists and Cons A cons is a record structure containing two components called the car and the cdr. Conses are used primarily to represent Lists. A list is a chain of conses linked by their cdr components and terminated by nil. The car components of the conses are called the elements of the lists. A list is notated by writing the elements of the list in order, separated by blank spaces and sorrounded by parenthesis. Ex: ( a b c). A dotted-list is one whose last cons doesn't have a nil for its cdr., after the last element and before the parenthesis is written a dot and the cdr of the last cons. Ex: ( a b c. 4), ( a . d) etc.. In Lisp ( a b . ( c d)) means same as the (a b c d)
  • 11. Arrays An array is an object with the components arranged according to a Cartesian co-ordinate system. The number of dimensions of an array is called its rank. An array element is specified by a sequence of elements.The length of the sequence must be equal to the rank of the array. One may refer to array elements using the function aref. Ex: (aref foo 2 1) refers to element (2,1) of the array.
  • 12.
  • 13. When accessing very large arrays in virtual-memory implementation.A simple-array is one which is not displaced to another array, has no fill pointer, and is not to have its size adjusted dynamically after creation.
  • 14. Arrays Arrays To create an array use the syntax: Make-array dimensions &key :element-type :initial-element :initial-contents: adjustable:fill-pointer: displaced to: displaced-index-offset. Ex: (make array ‘(4 2 3) : initial contents ‘(((a b c) (1 2 3)) ((d e f) (3 1 2)) ((g h i) (2 3 1)) ((j k l) (0 0 0))))
  • 15. Vectors One dimensional array is called vectors in lisp and constitute the type Lisp. Vectors and Lisps are collectively considered to be sequences. A general vectors is notated by notating the components in order sorrounded by #( and ) Ex: #( a b c d ), #( ), #( 1 2 3 ) etc.
  • 16. Structures Structures are instances of user-defined data types that have a fixed number of named components. Structures are declared using the defstruct construct. The default notation for a structure is: #s(structure-name slot-name-1 slot-value-1 slot-name-2 slot-value-2 ……….) Where #s indicates structure syntax, structure name is the name(symbol) the structure type, each slot-name is the name of the component and each corresponding slot value is the representation of the lisp object in that slot.
  • 17. Hash tables provide an efficient way of mapping any LIST object (a key) to an associate object. To work with hash tables CL provides the constructor function (make-hash-table) and the accessor function( get-hash). In order to look up a key and find the associated value, (use gethash) New entries are added to hash table using the setq and gethash functions. To remove an entry use remhash. Hash Tables
  • 18. Hash Tables Ex: (setq a (make-hash-table)) (setf (gethash ‘color a) ‘black) (setq (gethash ‘name a) ‘fred) (Gethash ‘color a)black (gethash ‘name a)fred (gethash ‘pointy a)nil
  • 19. Hash Tables Hash table functions Syntax: make-hash-table &key :test :size :rehash-size :rehash-threshold :test attribute determines how the attributes are compared, it must be one of the values( #’eq, #’eql, #’eql or one of the symbols(eq, eql, equal) :size attribute sets the initial size of the hash table. :rehash-size argument specifies how much to increase the size of the hash table when it becomes full. :rehash-threshold specifies how full the hash table can be before it must grow. Ex: (make-hash-table: re-hash size 1.5 :size (* number-of-widgets 43))
  • 20. Functions Functions are objects that can be invoked as procedures: These may take arguments and return values. A compiled function is a compiled-code object. A lambda-expression (a list whose car is the symbol lambda) may serve as a function.
  • 21.
  • 23. Appending multiple lists together to make a new list
  • 24. Extracting elements from the list to make a new list.Common lisp defines accessor function from first to tenth as a means of accessing the first ten elements of the list. Ex: (first ‘(a b c))A (third ‘(a b c))C Use the function nth to access an element from the arbitrary list. Ex: (nth 0 ‘(a b c))A (nth 1 ‘(a b c))B
  • 25. Data structures Data structures To check if a particular object is lisp or not,CL provides Listp function.It always returns either T or NIL Ex: (listp ‘(pontaic cadillac chevrolet))T (listp 99)NIL The function Length is used to get the number of elements in List as an integers. Ex: (length ‘(pontaic cadillac chevrolet))3 The member function is used to determine if the particular item is a member of the particular list. Ex: (member ‘dallas ‘(boston san-fransisco portland))NIL (member ‘san-fransisco’(boston san-fransisco portland))SAN-FRANSISCO PORTLAND
  • 26. Data structures Data structures continued.. Subseq is a part of the list used to return a portion of the List. Ex: (subseq ‘(a b c d) 1 3)1 3 (subseq ‘(a b c d) 1)b The function append is used to append any number of lists to an already existing list. Ex: (setq my-slides ‘(DATA TYPES)) (append my-slides ‘(IN LISP)) my-slides DATA TYPES IN LISP The function cons is used to add a single element to the List. Ex: (cons ‘a ‘(b c d))(A B C D)
  • 27. Data structures The function remove is used to remove the item from the list. Ex: (setq data ‘(1 2 3 4)) (setq data(remove 3 data)) data(1 2 4) Use the function sort with #’< to sort the list in ascending order and sort function with #’> to sort the list in descending order. Ex: (setq data (sort data #’<))(1 2 4) (setq data (sort data #’>))(4 2 1) The function union, intersection and set-difference takes two Lists and computes the corresponding set operation. Ex: (union ‘(1 2 3) ‘(7 8 1))(3 2 7 8 1) (intersection ‘(1 2) ‘(7 8 1))(1)
  • 28. Property lists(plists) Property lists are used to handle keyword-value pairs Plists is a simple list with each with even number of elements. (keyword-value pairs) Ex for a plist is: (:michigan “lansing” :illinois “springfield” :pennsylavania “harrisburg”) Getf function is used to access the members of plist. Ex: (getf ‘(:michigan “lansing” :illinois “springfield” :pennsylavania “harrisburg” : illinois)) “springfield”
  • 29. Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net Visit more self help tutorials