Skip to content

Commit 5e19e9f

Browse files
author
Symbolics
committed
Document aops:turn
1 parent 0f1a3ec commit 5e19e9f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

content/en/docs/Manuals/array-operations.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,38 @@ To create that array from a vector, use the `:inner` keyword:
460460
; (30 30 30))
461461
```
462462

463+
### turn
464+
465+
**`turn`** rotates an array by a specified number of clockwise 90° rotations. The axis of rotation is specified by RANK-1 (defaulting to 0) and RANK-2 (defaulting to 1). In the first example, we'll rotate by 90°:
466+
467+
```lisp
468+
(defparameter array-1 #2A((1 0 0)
469+
(2 0 0)
470+
(3 0 0)))
471+
(aops:turn array-1 1)
472+
;; #2A((3 2 1)
473+
;; (0 0 0)
474+
;; (0 0 0))
475+
```
476+
477+
and if we rotate it twice (180°):
478+
479+
```lisp
480+
(aops:turn array-1 2)
481+
;; #2A((0 0 3)
482+
;; (0 0 2)
483+
;; (0 0 1))
484+
```
485+
486+
finally, rotate it three times (270°):
487+
488+
```lisp
489+
(aops:turn array-1 3)
490+
;; #2A((0 0 0)
491+
;; (0 0 0)
492+
;; (1 2 3))
493+
```
494+
463495

464496
### map-array
465497

0 commit comments

Comments
 (0)