Home › Forums › kdb+ › Five easy pieces #4: Little Six › Re: Five easy pieces #4: Little Six
-
Very nice! Especially the use of Converge. Your expression makes it clear that the permutation returns to the original order and that the envoi has the order of the original.
Further thoughts: if you use Do with a left argument of 6, you can then use Apply At
@
to apply" "sv'2 cut
to the last item. This expression emphasises that the permutation returns the envoi to the original order.sest1:{1_raze” “,/:@[;6;” “sv’2 cut]6 @[;5 0 4 1 3 2]x}
Getting down to a single reference to the argument introduces the possibility of writing the function as a composition, which eliminates the tiny overhead of a lambda. Here we can use the bracket notation you introduced earlier for Do.
sest2:1_ raze ” “,/: @[;6;” “sv’2 cut] @[;5 0 4 1 3 2][6;] @
Above spaces clarify the structure a composition of five unaries:
1_
raze
" ",/:
@[;6;" "sv'2 cut]
@[;5 0 4 1 3 2][6;]
If you’ve read this far, test your understanding!
When projecting a binary function
f
onto its first argument (e.g. 6) we can elide the semicolon and write eitherf[6;]
orf[6]
. Why can we not do that here why does@[;5 0 4 1 3 2][6]
not work?Lastly, can
5 0 4 1 3 2
become a function of the stanza length assuming an even number of lines? That would support new forms, such as an octrina (I just made that word up) or a quatrina.