![]() |
VOOZH | about |
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
Output:
#(12 34 56 22 34)
#(12 34 56 22 34)
#(G E E K S)
#('G 'E 'E 'K 'S)In the given vector we can perform two operations. They are:
This is used to insert an element into a vector
Syntax:
(vector-push element array_name)
where
Example: LISP Program to create an empty array with size 10 and perform the vector push operation
Output:
#() #(1 2 3 4)
This function will remove the last inserted element at a time
Syntax:
(vector-pop array_name)
where
Example: POP items in an array
Output:
#() #(1 2 3 4) #(1 2 3) #(1 2)