Google


yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Back: Arrays Forward: Interpolating   FastBack: Arrays Up: Arrays FastForward: Graphics         Top: Yorick Contents: Table of Contents Index: Concept Index About: About this document

2.1 Creating Arrays

Including the span function introduced in the previous section, there are five common ways to originate arrays -- that is, to make an array out of scalar values:

[val1, val2, val3, ...]
The most primitive way to build an array is to enumerate the successive elements of the array in square brackets. The length of the array is the number of values in the list. An exceptional case is [], which is called "nil". A Yorick variable has the value nil before it has been defined, and [] is a way to write this special value.

array(value, dimlist)
Use array to "broadcast" (see section 2.6 Broadcasting and conformability) a value into an array, increasing its number of dimensions. A dimlist is a standard list of arguments used by several Yorick functions (see section 2.7 Dimension Lists). Often, the pseudo-index range function (see section 2.3.5 Creating a pseudo-index) is a clearer alternative to the array function.

span(start, stop, number)
Use span to generate a list of equally spaced values.

indgen(n)
indgen(lower:upper)
indgen(start:stop:step)
Use indgen ("index generator") instead of span to generate equally spaced integer values. By default, the list starts with 1.

spanl(start, stop, number)
Use spanl ("span logarithmically") to generate a list of numbers which increase or decrease by a constant ratio.