Just a quick follow-up... I'm amazed at the power of the combination of all of the recent changes by
@lexikos, as I rewrite a few of my libraries. Just these varref changes (discussed above) + enumerator changes + the function call changes... have enabled some pretty cool functional programming code. Below is a grouping or "chunking" enumerator I wrote in just a few lines. It uses the arity of the for..in to determine the chunk size:
Code: Select all
rpt(f, i) { ;repeat f(a_index) i times
loop i
f(a_index)
}
grp(xs) ;grouped enumerator of xs array; size of group matches for/in arity
=> {__enum : (_,a) => (len := xs.length // a, i := 0, (rs*)
=> (++i > len) ? 0 : (rpt(j => (%rs[j]% := xs[i*a-(a-j)]), a), 1))}
a := [2,4,6,8,10,12,14,16,18,20]
for x,y in grp(a)
msgbox(x ',' y) ;2,4 .. 6,8 .. 10,12 ..
for x,y,z in grp(a)
msgbox(x ',' y ',' z) ;2,4,6 .. 8,10,12 .. 14,16,18 ..
I'll ultimately use this to rework the "defaults" function described above, since it requires pairwise enumeration of a variadic. Thanks again for all the hard work, Lexikos! Rewriting code for this beta is truly a pleasure because of all the power you've unlocked.
"Languages should be designed not by piling feature on top of feature, but by removing the restrictions that make additional features appear necessary." —Scheme reference standard