array helper functions
-
@_JKDOS according to your post about push() and pop() I started doing some simple implementations of these, with the possibilities, that already exist in FUZE4.
Its maybe helping someone to simplify code or save time (SW-4464-9632-0709), of course its not as efficient, as language supported functions ;-) -
You can actually shorten some of that code down. Here's an example of your
shift
function reduced...function shift( a ) return a[ 1 : ]
What that does is grabs the entirety of the array beginning at the second position (because of base 0), and returns that. Your
pop
andresize
functions can benefit from this as well. Not actually sure if this is meant to be done this way, as this technique has been used for manipulating strings in groups since we can access them like an array (refer to my post in the Hints and Tips thread). However, unlike strings where we can append strings together, we can't with arrays, so functions you have likeslice
anddelete
could grab the first portion of the array in one go, but the second part will have to be filled in one element at a time.With that said, it would be nice to have built-in functionality of these.
-
Do you gain any performance improvements by doing array operations like Discostew suggested? Or does Fuze still loop through the whole array “under the hood”?
Is the “:” trick found somewhere in the documentation? It’s a bit cumbersome searching the forum ever time I want to find the usage...
-
Bye the way, @spikey, those functions are super useful!
-
@vinicity I could not find the discussion anymore about the array access shortcut. But I know there is one, maybe it answers the "documentation" question (can you help @Discostew ?). Interesting question if it performs better: it could, but also because it returns the value immediately and does not create an additional local variable. Volunteers for a test program?
-
Was it this one? https://fuzearena.com/forum/topic/70/hints-and-tips/9
-
@spikey, could you share/submit those functions above? Unless you have already, and I missed it?
I might throw together a little performance test tonight. -
@vinicity sure, cool. NQ5QBMNDN8
-
@spikey this will be interesting
-
I did some quick tests, and it seems that the modified functions are definitely faster. Between 4 and 10 times in my little test scenarios...