2021年1月22日星期五

Is there a programmatic way to elaborate the 'half-winds' in raku?

I have this working:

my %pnt = %( cardinal => <N E S W>,                ordinal  => <N NE E SE S SW W NW>,               half-winds => <N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW>,              );  

and I thought it may be possible to create the half-winds array programatically.

However, my pathetic attempts seem to be more long-winded:

my @cards = <N E S W>;   my @odds  = <NE SE SW NW>;  my @ords  = ( @cards Z @odds ).flat;   my @mids  = ( ( @cards Z~ @odds ) Z ( @cards.rotate(1) Z~ @odds ) ).flat;  my @halfs = ( @ords Z @mids ).flat;     say @cards; #[N E S W]  say @ords;  #[N NE E SE S SW W NW]   say @mids;  #[NNE ENE ESE SSE SSW WSW WNW NNW]  say @halfs; #[N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW]  

Is there a better / more concise alternative?

viz. https://en.wikipedia.org/wiki/Points_of_the_compass -- bonus points for quarter winds!

https://stackoverflow.com/questions/65853009/is-there-a-programmatic-way-to-elaborate-the-half-winds-in-raku January 23, 2021 at 05:29AM

没有评论:

发表评论