2008-01-05 17:27:15 -05:00
USING: help.markup help.syntax
2009-02-16 22:06:28 -05:00
kernel kernel.private prettyprint sequences.private sequences ;
2007-09-20 18:09:08 -04:00
IN: arrays
2009-02-16 22:06:28 -05:00
ARTICLE: "arrays-unsafe" "Unsafe array operations"
"These two words are used internally by the Factor implementation. User code should never need to call them; instead use " { $link nth } " and " { $link set-nth } "."
2009-10-01 15:56:36 -04:00
{ $subsections
array-nth
set-array-nth
} ;
2009-02-16 22:06:28 -05:00
2007-09-20 18:09:08 -04:00
ARTICLE: "arrays" "Arrays"
2009-02-16 22:06:28 -05:00
"The " { $vocab-link "arrays" } " vocabulary implements fixed-size mutable sequences which support the " { $link "sequence-protocol" } "."
$nl
"The " { $vocab-link "arrays" } " vocabulary only includes words for creating new arrays. To access and modify array elements, use " { $link "sequences" } " in the " { $vocab-link "sequences" } " vocabulary."
2007-09-20 18:09:08 -04:00
$nl
2009-02-16 22:06:28 -05:00
"Array literal syntax is documented in " { $link "syntax-arrays" } ". Resizable arrays also exist and are known as " { $link "vectors" } "."
2007-09-20 18:09:08 -04:00
$nl
"Arrays form a class of objects:"
2009-10-01 15:56:36 -04:00
{ $subsections
array
array?
}
2007-09-20 18:09:08 -04:00
"Creating new arrays:"
2009-10-01 15:56:36 -04:00
{ $subsections
>array
<array>
}
2007-09-20 18:09:08 -04:00
"Creating an array from several elements on the stack:"
2009-10-01 15:56:36 -04:00
{ $subsections
1array
2array
3array
4array
}
2010-06-22 15:46:54 -04:00
"Resizing arrays:"
{ $subsections resize-array }
2007-09-20 18:09:08 -04:00
"The class of two-element arrays:"
2009-10-01 15:56:36 -04:00
{ $subsections pair }
2009-02-16 22:06:28 -05:00
"Arrays can be accessed without bounds checks in a pointer unsafe way."
2009-10-01 15:56:36 -04:00
{ $subsections "arrays-unsafe" } ;
2007-09-20 18:09:08 -04:00
ABOUT: "arrays"
HELP: array
{ $description "The class of fixed-length arrays. See " { $link "syntax-arrays" } " for syntax and " { $link "arrays" } " for general information." } ;
2011-10-20 22:36:11 -04:00
HELP: <array>
2007-09-20 18:09:08 -04:00
{ $values { "n" "a non-negative integer" } { "elt" "an initial element" } { "array" "a new array" } }
{ $description "Creates a new array with the given length and all elements initially set to " { $snippet "elt" } "." } ;
HELP: >array
2014-05-23 17:24:04 -04:00
{ $values { "seq" sequence } { "array" array } }
2007-09-20 18:09:08 -04:00
{ $description "Outputs a freshly-allocated array with the same elements as a given sequence." } ;
HELP: 1array
{ $values { "x" object } { "array" array } }
{ $description "Create a new array with one element." } ;
{ 1array 2array 3array 4array } related-words
HELP: 2array
{ $values { "x" object } { "y" object } { "array" array } }
{ $description "Create a new array with two elements, with " { $snippet "x" } " appearing first." } ;
HELP: 3array
{ $values { "x" object } { "y" object } { "z" object } { "array" array } }
{ $description "Create a new array with three elements, with " { $snippet "x" } " appearing first." } ;
HELP: 4array
{ $values { "w" object } { "x" object } { "y" object } { "z" object } { "array" array } }
{ $description "Create a new array with four elements, with " { $snippet "w" } " appearing first." } ;
2011-10-20 22:36:11 -04:00
HELP: resize-array
2010-06-22 15:46:54 -04:00
{ $values { "n" "a non-negative integer" } { "array" array } { "new-array" array } }
{ $description "Resizes the array to have a length of " { $snippet "n" } " elements. When making the array shorter, this word may either create a new array or modify the existing array in place. When making the array longer, this word always allocates a new array, filling remaining space with " { $link f } "." }
{ $side-effects "array" } ;
2007-09-20 18:09:08 -04:00
HELP: pair
{ $class-description "The class of two-element arrays, known as pairs." } ;