2
19
Fork
You've already forked array
3

In select, support indexes with fewer dimensions than the argument #8

Open
opened 2024年04月11日 07:33:19 +02:00 by loke · 3 comments
Owner
Copy link

Using a negative argument to select should could the index from the back

Using a negative argument to select should could the index from the back
Author
Owner
Copy link

The implementation should mimic the BQN behaviour:

 0‿ ̄1⊏4‿2‿3⥊↕25
┌─
╎ 0 1 2
 3 4 5
 18 19 20
 21 22 23
 ┘
 ≢0‿ ̄1⊏4‿2‿3⥊↕25
⟨ 2 2 3 ⟩
The implementation should mimic the BQN behaviour: ``` 0‿ ̄1⊏4‿2‿3⥊↕25 ┌─ ╎ 0 1 2 3 4 5 18 19 20 21 22 23 ┘ ≢0‿ ̄1⊏4‿2‿3⥊↕25 ⟨ 2 2 3 ⟩ ```
Collaborator
Copy link

Examples of how I suspect the operator to behave

> 0  ̄3  ̄1  "index"
"idx"
> 0  ̄1  3 3⍴⍳9
────┐
0 1 2
6 7 8
└─────┘
> 0  ̄1  5 2 3⍴⍳30
┌┌───────┐
 0 1 2
││ 3 4 5
│├───────┤
24 25 26
││27 28 29
└└────────┘

Currently, does not work on higher-rank arrays, so that will also need to be addressed, but it's behavior should be similar to (⌷⍨∘⊃⍨⍤0 99), as defined by Adám Brudzewsky in his Dyalog Vision, with the addition of supporting negative indices, which are unsupported in Dyalog.

Given n is the length of a list, and i is an index...
A negative index i ≥ ̄n acts as n + i. When i < ̄n, it would still be an Index out of bounds error.

Examples of how I suspect the operator to behave ```apl > 0 ̄3 ̄1 ⊇ "index" "idx" > 0 ̄1 ⊇ 3 3⍴⍳9 ┌→────┐ ↓0 1 2│ │6 7 8│ └─────┘ > 0 ̄1 ⊇ 5 2 3⍴⍳30 ┌┌→───────┐ │↓ 0 1 2│ ││ 3 4 5│ │├→───────┤ │↓24 25 26│ ││27 28 29│ └└────────┘ ``` Currently, `⊇` does not work on higher-rank arrays, so that will also need to be addressed, but it's behavior should be similar to `(⌷⍨∘⊃⍨⍤0 99)`, as defined by Adám Brudzewsky in his [Dyalog Vision](https://github.com/abrudz/dyalog_vision), with the addition of supporting negative indices, which are unsupported in Dyalog. Given `n` is the length of a list, and `i` is an index... A negative index `i ≥ ̄n` acts as `n + i`. When `i < ̄n`, it would still be an `Index out of bounds` error.
loke changed title from (削除) Support negative arguments in select (削除ここまで) to In select, support indexes with fewer dimensions than array being read from 2024年04月12日 07:35:57 +02:00
loke changed title from (削除) In select, support indexes with fewer dimensions than array being read from (削除ここまで) to In select, support indexes with fewer dimensions than the argument 2024年04月12日 07:36:10 +02:00
Collaborator
Copy link

I've built a new Kap today and confirmed feature working as expected on vectors

> 0  ̄3  ̄1  "index"
"idx"
> 0  ̄1  "a"
"aa"

Flattening a matrix to a vector (and then mixing after) to test it on 2d matrix for now.

>  0  ̄1  ,/ 3 3⍴⍳9
────┐
0 1 2
6 7 8
└─────┘
I've built a new Kap today and confirmed feature working as expected on vectors ```apl > 0 ̄3 ̄1 ⊇ "index" "idx" > 0 ̄1 ⊇ "a" "aa" ``` Flattening a matrix to a vector (and then mixing after) to test it on 2d matrix for now. ```apl > ⊃ 0 ̄1 ⊇ ,/ 3 3⍴⍳9 ┌→────┐ ↓0 1 2│ │6 7 8│ └─────┘ ```
Sign in to join this conversation.
No Branch/Tag specified
master
jdk25
tmp-generic-window-management
experiment-assign-to-function-expression
feature-error-highlight
feature-mosaic-ui
feature-sdl
feature-rationalise-reduced
adaptive-experiment
bugfix-linux-charconversions
vector-ops
vector-jvm
sane-reduce
formatter
bitarrays
array-builder
jvm-android-split-new
nested-function-calls-bug
multi-dimensional-string-formatting
ride-impl
codeberg-test
jvm-android-split
libreoffice-module-classloader
optimise-single-element-array
parser-callbacks
new-jline-completion
java-readline
test-tools
int-list-opt
linux-ffi
ffi
isqrt
inter-thread-datatransfer
metadata-highlight
numeric-total-ordering
libreoffice
langbar-javafx
port-mpbignum-to-wasmjs
aesh-test
zero-parser
java21
fxcontrols-spreadsheet-fork
javafx-reporting
new-http
new-optimiser
sixel-renderer
native-input
lambda-scope
custom-renderer
formatter-test
local-functions-fix
kap-rational
bigint2
bigint
reporting
dynamic-assign
structure-viewer2
return-impl
escape-analysis
fork-new-syntax
structural-under
axis-eval
binomial-impl
new-enclose
short-fn-definition
compose-impl
specialised-arrays
ops
domino
clientweb
lcm
gui-experiments
suspend
thread-support
closures_wip
inner-join
maths_axis
keyboard
resultlist3
error-locations
axis-work
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
loke/array#8
Reference in a new issue
loke/array
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?