How to resolve the algorithm Array concatenation step by step in the Common Lisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Array concatenation step by step in the Common Lisp programming language
Table of Contents
Problem Statement
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Array concatenation step by step in the Common Lisp programming language
Source code in the common programming language
(concatenate 'vector #(0 1 2 3) #(4 5 6 7))
=> #(0 1 2 3 4 5 6 7)
(setf arr1 (make-array '(3) :initial-contents '(1 2 3)))
(setf arr2 (make-array '(3) :initial-contents '(4 5 6)))
(setf arr3 (make-array '(3) :initial-contents '(7 8 9)))
(setf arr4 (make-array '(6)))
(setf arr5 (make-array '(9)))
(setf arr4 (concatenate `(vector ,(array-element-type arr1)) arr1 arr2))
(format t "~a" "concatenate arr1 and arr2: ")
(write arr4)
(terpri)
(setf arr5 (concatenate `(vector ,(array-element-type arr1)) arr4 arr3))
(format t "~a" "concatenate arr4 and arr3: ")
(write arr5)
(terpri)
You may also check:How to resolve the algorithm Array length step by step in the ATS programming language
You may also check:How to resolve the algorithm Long year step by step in the Draco programming language
You may also check:How to resolve the algorithm Forward difference step by step in the SequenceL programming language
You may also check:How to resolve the algorithm Knapsack problem/Unbounded step by step in the C_sharp programming language
You may also check:How to resolve the algorithm Rename a file step by step in the NetRexx programming language