Make Arrays Useful

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

Make Arrays Useful

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]?
User avatar
Chunjee
Posts: 1601
Joined: 18 Apr 2014, 19:05
Contact:

Re: Make Arrays Useful

24 Feb 2024, 01:25

I also think this would be a great addition
Ralf_Reddings200244
Posts: 121
Joined: 11 Mar 2023, 14:16

Re: Make Arrays Useful

15 May 2024, 16:53

Yes please, these would be so usefull to have. I was actually hoping some of these would be pressent in V2.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 15 guests