Vectors in LISP Last Updated : 26 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss Vectors in LISP. Vectors in LISP are one-dimensional arrays which are also known as sequences. We can create a vector using vector function and # symbol Syntax: variable_name(vector element1 element2 ... element n) or variable_name #(element1 element2 ... element n) Example: LISP Program to create integer and character vectors and display Lisp ;create a vector with 5 integer elements (setf data1 (vector 12 34 56 22 34)) ;display (write data1) (terpri) ;create a vector with 5 integer elements using # symbol (setf data1 #( 12 34 56 22 34)) ;display (write data1) (terpri) ;create a vector with 5 character elements (setf data2 (vector 'g 'e 'e 'k 's)) ;display (write data2) (terpri) ;create a vector with 5 character elements (setf data2 #( 'g 'e 'e 'k 's)) ;display (write data2) Output: #(12 34 56 22 34) #(12 34 56 22 34) #(G E E K S) #('G 'E 'E 'K 'S)Vector operations: In the given vector we can perform two operations. They are: push operationpop operation1. Push Operation: This is used to insert an element into a vector Syntax: (vector-push element array_name) where array_name is an input arrayelement is an element to be pushed in an array Example: LISP Program to create an empty array with size 10 and perform the vector push operation Lisp ;create an empty array with size 10 (setq my_array (make-array 10 :fill-pointer 0)) ;display array (write my_array) (terpri) ;push number 1 into array (vector-push 1 my_array) ;push number 2 into array (vector-push 2 my_array) ;push number 3 into array (vector-push 3 my_array) ;push number 4 into array (vector-push 4 my_array) ;display (write my_array) Output: #() #(1 2 3 4)2. Pop Operation: This function will remove the last inserted element at a time Syntax: (vector-pop array_name) where array_name is the input array Example: POP items in an array Lisp ;create an empty array with size 10 (setq my_array (make-array 10 :fill-pointer 0)) ;display array (write my_array) (terpri) ;push number 1 into array (vector-push 1 my_array) ;push number 2 into array (vector-push 2 my_array) ;push number 3 into array (vector-push 3 my_array) ;push number 4 into array (vector-push 4 my_array) ;display (write my_array) ;pop 1 item (vector-pop my_array) (terpri) ;display array (write my_array) ;pop again 1 item (vector-pop my_array) (terpri) ;display array (write my_array) Output: #() #(1 2 3 4) #(1 2 3) #(1 2) Comment More infoAdvertise with us Next Article List of Vectors in R S saisravanprojects Follow Improve Article Tags : LISP LISP-Basics Similar Reads Vectors in Julia Vectors in Julia are a collection of elements just like other collections like Array, Sets, Dictionaries, etc. Vector are different from Sets because vectors are ordered collections of elements, and can hold duplicate values, unlike sets which require all the elements to be unique. Vectors are one-d 5 min read List of Vectors in R Vectors are a sequence of elements belonging to the same data type. A list in R, however, comprises of elements, vectors, variables or lists which may belong to different data types. In this article, we will study how to create a list consisting of vectors as elements and how to access, append and d 6 min read Numbers in LISP LISP is a list processing programming language. It is widely used in the manipulation of data strings. It provides an input and output library. LISP provides a macro system and provides well control structures for the manipulation of data. LISP Math Function:floor:Â floor returns the nearest smalles 2 min read Predicates in LISP In this article, we will discuss predicates. Predicates are similar to functions that will be used to test their arguments for conditions. They will return NIL if the conditions are not met, if the conditions are met, they will return T. Types of predicates: Below is a list of major Predicates with 5 min read Structures in LISP LISP, is a list processing, is a programming language widely used in working with data manipulation. Structures are used defines data types, that have the ability to combine with another data type to complete the given task. Attribute used: The defstruct attribute is used to create an instance of a 2 min read Lists in LISP Lists in common LISP is simply a single Linked list. In LISP, Lists are designed as a chain of records. While talking about record structures in LISP, the concept of Cons is vital. Cons in LISP is a record structure with 2 Â primary components. A cons function takes in 2 arguments and returns a new c 2 min read Like