factor/library/collections/arrays.facts

43 lines
2.0 KiB
Plaintext

IN: arrays
USING: help kernel kernel-internals prettyprint strings
vectors ;
HELP: array
{ $description "The class of fixed-length arrays. See " { $link "syntax-arrays" } " for syntax and " { $link "arrays" } " for general information." } ;
HELP: <array> ( n elt -- array )
{ $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" } "." }
{ $see-also <quotation> <string> <sbuf> <vector> } ;
HELP: >array
{ $values { "seq" "a sequence" } { "array" "an array" } }
{ $description "Outputs a freshly-allocated array with the same elements as a given sequence." }
{ $see-also >string >sbuf >vector >quotation } ;
HELP: 1array
{ $values { "x" "an object" } { "array" "an array" } }
{ $description "Create a new array with one element." }
{ $see-also 2array 3array ch>string } ;
HELP: 2array
{ $values { "x" "an object" } { "y" "an object" } { "array" "an array" } }
{ $description "Create a new array with two elements." }
{ $see-also 1array 3array ch>string } ;
HELP: 3array
{ $values { "x" "an object" } { "y" "an object" } { "z" "an object" } { "array" "an array" } }
{ $description "Create a new array with three elements." }
{ $see-also 1array 2array ch>string } ;
HELP: resize-array ( n array -- newarray )
{ $values { "n" "a non-negative integer" } { "array" "an array" } { "newarray" "a new array" } }
{ $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 } "." } ;
HELP: byte-array
{ $description "The class of byte arrays." } ;
HELP: <byte-array> ( n -- byte-array )
{ $values { "n" "a non-negative integer" } { "byte-array" "a new byte array" } }
{ $description "Creates a new byte array holding " { $snippet "n" } " bytes." } ;