Dyalog Primer - Variables
a←2 3 4
a←3 4 5 7 13 8 9⍴1
no need to pre-declare variables, they spring into life on demand.
the value of a variable by assigning a value (the left-pointing arrow).
the name on its own and the value is displayed in the session window.
can replace entire variables whenever you want.
may be multi-dimensional.
are settings within APL (index origin is an example) that can affect
how the same code can behave differently in some circumstances.
doesn't mind if you reuse a variable so that it contains characters
rather than numbers - and vice-versa.
- APL has
characters (you can't do arithmetic with characters) and numbers (you
can do arithmetic with numbers).
essentially, numbers are numbers - APL doesn't make the programmer
worry about whether a number is an integer, or a floating-point, or how
many decimal places are needed. It just does the best job it
When you get proficient/ambitious, you'll be able to force it
do fancy stuff as and when that becomes important to you.
an array, elements can be different types.
- You can
wrap things up - "enclosing" them.
variables act like scalars.
- You can make
variables which have enclosed elements - without reasonable limit.
- Dyalog Language Reference
- Legal names
- Prototypes and fill items
- Supplied workspace DISPLAY
- Create three numeric vectors each containing 100 different integers, call them a b and c
- Reshape a into an array with 2 planes each consisting of 5 rows and 10 columns.
two new vectors from b, each 120 long, calling them b1 and b2. The last
20 values in b1 should be the same as the first 20 values. The
last 20 values in b2 should be zero.
- Replace every fifth value in c with the letter 'x'.
- Make a rank-2 array where each element is itself a 2-row-2-column array of the integers 0 1 2 3.