]> gitweb.factorcode.org Git - factor.git/blob - core/arrays/arrays-docs.factor
Fix permission bits
[factor.git] / core / arrays / arrays-docs.factor
1 USING: help.markup help.syntax
2 kernel kernel.private prettyprint sequences.private ;
3 IN: arrays
4
5 ARTICLE: "arrays" "Arrays"
6 "Arrays are fixed-size mutable sequences (" { $link "sequence-protocol" } "). The literal syntax is covered in " { $link "syntax-arrays" } ". Resizable arrays also exist and are called vectors; see " { $link "vectors" } "."
7 $nl
8 "Array words are in the " { $vocab-link "arrays" } " vocabulary. Unsafe implementation words are in the " { $vocab-link "sequences.private" } " vocabulary."
9 $nl
10 "Arrays form a class of objects:"
11 { $subsection array }
12 { $subsection array? }
13 "Creating new arrays:"
14 { $subsection >array }
15 { $subsection <array> }
16 "Creating an array from several elements on the stack:"
17 { $subsection 1array }
18 { $subsection 2array }
19 { $subsection 3array }
20 { $subsection 4array }
21 "Arrays can be accessed without bounds checks in a pointer unsafe way."
22 { $subsection array-nth }
23 { $subsection set-array-nth }
24 "The class of two-element arrays:"
25 { $subsection pair } ;
26
27 ABOUT: "arrays"
28
29 HELP: array
30 { $description "The class of fixed-length arrays. See " { $link "syntax-arrays" } " for syntax and " { $link "arrays" } " for general information." } ;
31
32 HELP: <array> ( n elt -- array )
33 { $values { "n" "a non-negative integer" } { "elt" "an initial element" } { "array" "a new array" } }
34 { $description "Creates a new array with the given length and all elements initially set to " { $snippet "elt" } "." } ;
35
36 HELP: >array
37 { $values { "seq" "a sequence" } { "array" array } }
38 { $description "Outputs a freshly-allocated array with the same elements as a given sequence." } ;
39
40 HELP: 1array
41 { $values { "x" object } { "array" array } }
42 { $description "Create a new array with one element." } ;
43
44 { 1array 2array 3array 4array } related-words
45
46 HELP: 2array
47 { $values { "x" object } { "y" object } { "array" array } }
48 { $description "Create a new array with two elements, with " { $snippet "x" } " appearing first." } ;
49
50 HELP: 3array
51 { $values { "x" object } { "y" object } { "z" object } { "array" array } }
52 { $description "Create a new array with three elements, with " { $snippet "x" } " appearing first." } ;
53
54 HELP: 4array
55 { $values { "w" object } { "x" object } { "y" object } { "z" object } { "array" array } }
56 { $description "Create a new array with four elements, with " { $snippet "w" } " appearing first." } ;
57
58 HELP: resize-array ( n array -- newarray )
59 { $values { "n" "a non-negative integer" } { "array" array } { "newarray" "a new array" } }
60 { $description "Creates a new array of " { $snippet "n" } " elements. The contents of the existing array are copied into the new array; if the new array is shorter, only an initial segment is copied, and if the new array is longer the remaining space is filled in with "{ $link f } "." } ;
61
62 HELP: pair
63 { $class-description "The class of two-element arrays, known as pairs." } ;