Assignment
Jump to navigation
Jump to search
You can assign a value to a variable with the glyph: '←'.
Common examples (boxing on, and ⎕io is 0):
mat←(1 2 3)(1 2 3) mat ┌─────┬─────┐ │1 2 3│1 2 3│ └─────┴─────┘ mat[0]←1 ⍝ indexed assignment mat ┌─┬─────┐ │1│1 2 3│ └─┴─────┘ mat←3 3⍴⍳9 mat 0 1 2 3 4 5 6 7 8 mat[0 1;] ⍝ 1 semicolon is necessary when dealing with 2D arrays, 2 semicolons for 3D arrays etc. 0 1 2 3 4 5 mat[0 1;0 1]←0 mat 0 0 2 0 0 5 6 7 8 ⍝ incrementing (or any dyadic function) parts of an array mat←3 3⍴0 mat 0 0 0 0 0 0 0 0 0 mat[0 1;1]+←1 mat 0 1 0 0 1 0 0 0 0 mat[1;1],←'x' mat 0 1 0 0 x 0 0 0 0