Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/Array-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,26 @@ The primitive rank operator `F⍤k` was introduced in Dyalog version 14.0. An AP
}
```

## An APL model of the rank operator
The primitive rank operator `F⍤k` was introduced in Dyalog version 14.0. An APL model compatible with earlier versions is as follows:
```APL
_Rank_←{
⍺←{⍵}
⍺ ⍺⍺{⍺←{⍵} ⋄ ⍺ ⍺⍺ ⍵}{
0 1000::⎕SIGNAL ⎕EN
effrank←{0≤⍺:⍺⌊⍴⍴⍵ ⋄ 0⌈⍺+⍴⍴⍵} ⍝ effective rank
cells←{⊂[(-⍺ effrank ⍵)↑⍳⍴⍴⍵]⍵}
(m l r)←⌽3⍴⌽⍵⍵
⎕ML←0 ⍝ needed by ↑⍵
0=⎕NC'⍺':↑⍺⍺¨(m cells ⍵) ⍝ monadic case
x←l cells ⍺
y←r cells ⍵
((⍴x)≡⍴y)⍱0=(⍴⍴x)⌊⍴⍴y:⎕SIGNAL 4+(⍴⍴x)≡⍴⍴y
↑x ⍺⍺¨y ⍝ dyadic case
}⍵⍵{⍵}⍵
}
```

## Reduce on an empty vector?
For your interest, here are some reductions of note. Try to ask yourself why they give the results they do. Could they have been given different definitions?

Expand Down
5 changes: 4 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ markdown_extensions:
- abbr
extra_javascript:
- javascripts/config.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
theme:
name: material
Expand All @@ -23,6 +22,10 @@ theme:
- navigation.instant
extra_css:
- style/main.css
plugins:
- privacy
- search

nav:
- About: index.md
- First Steps: First-steps.md
Expand Down
Loading