skinnyjilo.blogg.se

Winds rss reader
Winds rss reader





winds rss reader

Leaving the quarter winds as an exercise for the reader The 32 points of "quarter winds"Īs Liz notes, a simple superset solution that includes hers and quarter winds would just entail: The rest of this answer is merely justification of my shameless bonus point scavenging. batch(8) batches the points back up into groups of 8 corresponding to the four quadrants ready for pretty printing. Without it there would be repeats of the four cardinal points ( ). Unique removes any elements of a list that are repeated. =unique applies a method and then assigns the result back to its invocant, mutating it in place.

#Winds rss reader code

(In my original version of this answer my code was wrong because I lined up the. The unspace makes it take the whole quadrant.map( *.trans: 'NE'=>'SW') expression as its operand. Without it the | takes just quadrant as its operand. is an "unspace", a way to indicate to the compiler that it should parse the code as if the slash and whitespace wasn't there. I use trans because it's succinct, but subst can always do the same stuff a trans does, even if it takes a lot more lines, and in Rakudo 2020.12 subst is around 5x-10x faster for almost all cases. The redundant E is there for the first transliteration because it felt a bit clearer than dropping it I could also have added *.trans: 'NE'=>'NE' for the first quadrant but that felt less clear. *.trans: 'NE'=>'SE' is a lambda that transliterates each N character to S and each E to E. map(.) applies a function or lambda to each element in its invocant list. reverse reverses a list, corresponding to the way the wind points notation reverses between NE/SW and SE/NW. Prefix | "slips" the value on its right the net effect of using it on each of the four quadrants is that the resulting list contains 32 elements rather than 4. Perhaps I get some bonus points for explaining the above: TL DR For no good reason, this nanswer goes after just the bonus points. flat.rotor(2 => -1).map(~*.sort(*.chars)) given the inner flattening can be replaced with a use of the | slip operator: say flat $_ Z (|$_.).rotor(2 => -1).map(~*.sort(*.chars)) given is still longer than just listing them out in the first place, which is what I'd probably do, but it was fun trying to beat that anyway. join can just become list stringification: say flat $_ Z. If we want it shorter, the duplicate mention of can go away with a given: say flat $_ Z. Which finally looks about right: (NNE ENE ESE SSE SSW WSW WNW NNW)Įxcept that the half winds are these placed between the principal winds, which can be solved with zipping them and flattening the result: say flat Z => -1).map(*.sort(*.chars).join)įinally giving us: (N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW) The cardinal winds are the one character ones, which can be fixed with a sort: say => -1).map(*.sort(*.chars).join) With the cardinal wind coming first and the intercardinal wind second Which isn't right yet, because the next thing the article says is: We get: (NNE NEE ESE SES SSW SWW WNW NWN) Giving: ((N NE) (NE E) (E SE) (SE S) (S SW) (SW W) (W NW) (NW N)) OK, we can include N again, at the cost of a little beauty: say => -1) Which sadly has an off by one problem, because it misses (NW, N).

winds rss reader winds rss reader

Which gives us: ((N NE) (NE E) (E SE) (SE S) (S SW) (SW W) (W NW)) This means we want to take principal winds in overlapping pairs, which rotor could do fairly neatly: say => -1) The name of each half-wind is constructed by combining the names of the principal winds to either side Then we can follow the definition a la Wikipedia: Assuming we have the principal winds to hand: my =







Winds rss reader