From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/array-functions.html | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 devdocs/elisp/array-functions.html (limited to 'devdocs/elisp/array-functions.html') diff --git a/devdocs/elisp/array-functions.html b/devdocs/elisp/array-functions.html new file mode 100644 index 00000000..d0cf3231 --- /dev/null +++ b/devdocs/elisp/array-functions.html @@ -0,0 +1,64 @@ +

Functions that Operate on Arrays

In this section, we describe the functions that accept all types of arrays.

Function: arrayp object +
+

This function returns t if object is an array (i.e., a vector, a string, a bool-vector or a char-table).

(arrayp [a])
+     ⇒ t
+(arrayp "asdf")
+     ⇒ t
+(arrayp (syntax-table))    ;; A char-table.
+     ⇒ t
+
+
+
Function: aref arr index +
+

This function returns the indexth element of the array or record arr. The first element is at index zero.

(setq primes [2 3 5 7 11 13])
+     ⇒ [2 3 5 7 11 13]
+(aref primes 4)
+     ⇒ 11
+
+
(aref "abcdefg" 1)
+     ⇒ 98           ; b’ is ASCII code 98.
+
+

See also the function elt, in Sequence Functions.

+
+
Function: aset array index object +
+

This function sets the indexth element of array to be object. It returns object.

(setq w (vector 'foo 'bar 'baz))
+     ⇒ [foo bar baz]
+(aset w 0 'fu)
+     ⇒ fu
+w
+     ⇒ [fu bar baz]
+
+ +
;; copy-sequence copies the string to be modified later.
+(setq x (copy-sequence "asdfasfd"))
+     ⇒ "asdfasfd"
+(aset x 3 ?Z)
+     ⇒ 90
+x
+     ⇒ "asdZasfd"
+
+

The array should be mutable. See Mutability.

If array is a string and object is not a character, a wrong-type-argument error results. The function converts a unibyte string to multibyte if necessary to insert a character.

+
+
Function: fillarray array object +
+

This function fills the array array with object, so that each element of array is object. It returns array.

(setq a (copy-sequence [a b c d e f g]))
+     ⇒ [a b c d e f g]
+(fillarray a 0)
+     ⇒ [0 0 0 0 0 0 0]
+a
+     ⇒ [0 0 0 0 0 0 0]
+
+
(setq s (copy-sequence "When in the course"))
+     ⇒ "When in the course"
+(fillarray s ?-)
+     ⇒ "------------------"
+
+

If array is a string and object is not a character, a wrong-type-argument error results.

+
+

The general sequence functions copy-sequence and length are often useful for objects known to be arrays. See Sequence Functions.

+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/Array-Functions.html +

+
-- cgit v1.2.3