Make Arrays Useful

Propose new features and changes
iseahound
Posts: 1447
Joined: 13 Aug 2016, 21:04
Contact:

Make Arrays Useful

Post by iseahound » 23 Feb 2024, 12:47

Arrays leave a lot to be desired in AutoHotkey and are at this point rather inferior to Map().

Issue #1: Allocate Arrays in a single line.

It should be possible to do the following in a single line. Even Python allows this via 5*["default value"]

Code: Select all

a := []
a.length := 5
Issue #2: Add useful methods

.sort() - Should be able to sort array element. Also, should accept a user defined sorting function.
.apply() - Should be able to apply a user defined function to each element of the array.
.fold() - Would allow for some simple functions such as sum(). Make it left to right to avoid lfold and rfold, the user can specify .reverse().
.count() - Counts the number of times an element occurs.
.reverse() - To make iterating backwards possible.

Less Important but still useful:
  • Perhaps setting a zero element turns it into a zero-indexed array.
  • Not sure what to do with IndexError and a[100]?


Post Reply

Return to “Wish List”