Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

functions for statistics/Dataset manipulation of arrays


  • Please log in to reply
No replies to this topic
Scratch
  • Members
  • 108 posts
  • Last active: Mar 16 2014 08:02 PM
  • Joined: 22 Jan 2009
If native array support makes it in AHK2, perhaps oppertunity
arises to implement often used dataset query/manipulation
functions

functions like sort, count

e.g:

Sort (pseudo) arrays

Sort, region[] : sorts whole array region
Sort, region[1..10], D : sorts items 1..10 in Descending order
Sort, region[1,3,5] : sorts items 1, 3, 5
Sort, region[1..5,10..20] : sorts 1..5 and 10..20

Count (pseudo) arrays

Count, region[] ; Counts all of array region and sets variable a_count

Count, region [], =, "Europe" : counts all items containing √čurope
Count,region[], =, "*America" : counts North-America, South America

Count, numbers[1..10], > 45 : count numbers > 45 in 1...10

more complex query:
Count, Max, numbers[1..10,20,21,22,50..100], > 45 AND < 70

Count, Str, mixedarray[] : counts all items that are strings in a mixed array containing numbers and strings

Count, StrLngth, scrabblewords[], > 8 : counts number of scrabbelwords
larger than stringlength 8

Count, SumStr, scrabblewords[] : count sum of all stringlength

more examples of return variables:

:a_count : number of counted items
a_countmin : lowest value
a_countmax : highest value
a_countavg : average
a_countstr : number of strings
a_countnum : number of numbers, not strings
a_countempty: number of empty variables in (pseudo)array
a_countnonempty : you guessed it....
a_countadd : sum of all counted items
a_countprod : product of all counted items
a_countsub : subtract
a_countdiv : divide
a_countmod : modulus
a_countdev : standarddeviation
etc....

perhaps dataset manipulation could be extented to include
section of ini files as well, e.g:


Sort, contacts.ini, D : sorts and writes back whole contacts.ini in descending order

Sort, contact.ini, sections : only sort the section names,
do not sort the keys and values contained by those sections

Sort, contact.ini keys,values : only sort keys and values (in that order),
do not sort on section names

Count, contacts.ini : counts all keys in all sections of contacts.ini, producing total number of contacts

Count, contacts.ini, america : counts number of keys in section [america]

Count, contacts.ini, *america, =, "John" : counts number of keys containing "John" in sections [northamerica] and [southamerica[ in contacts.ini