From OpenSCADAWiki
Revision as of 19:10, 28 September 2017 by FuzzyBot (Talk | contribs) (Importing a new version from external source)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Array provides the special property "length" to get the array size "var = arr.length;". Also array provides the following functions:

  • string join( string sep = "," ), string toString( string sep = "," ), string valueOf( string sep = "," ) — Returns the string with the array elements separated by sep or the character ','.
  • Array concat( Array arr ); — Adds to the initial array the elements of the arr array. Returns the initial array with changes.
  • int push( ElTp var, ... ); — Places the element(s) var to the end of the array, as to the stack. Returns the new array size.
  • ElTp pop( ); — Deleting of the last element of the array and return of its value, as from the stack.
  • Array reverse( ); — Changing the order of the elements of the array. Returns the initial array with changes.
  • ElTp shift( ); — The shift of the array to the top. The first element is removed and its value is returned.
  • int unshift( ElTp var, ... ); — Shift element(s) var to the array. The first element to the 0, second to the 1 and so on.
  • Array slice( int beg, int end ); — Returns an array fragment from beg to end (exclude). If the value of beginning or end is negative, then the count is made from the end of the array. If the end is not specified, then the end is the end of the array.
  • Array splice( int beg, int remN, ElTp val1, ElTp val2, ... ); — Inserts, deletes or replaces the elements of the array. Returns the removed elements array. Firstly it is made the removing of elements from the position beg and in the quantity of remN, and then the values val1 are inserted and so on, beginning from the position beg.
  • Array sort( ); — Sort array elements in lexicographical order.