Box the compass: Difference between revisions

J: bugfix
(J: add another example)
(J: bugfix)
Line 27:
tween=:1 :'[,m,tolower@]'
by=:' by 'tween
hy=:'-'tween&>/@(/: #@>)@;
fixup=: (rplc ''|.@;{.@;:@tolower) ^:(' '&e.)L:0
points=:fixup ,2 ([;by;'-'tweenhy;by~)&>/\ cardinal
indice=: 32 | 0.5 <.@+ %&11.25
deg2pnt=: points {~ indice</lang>
Line 43 ⟶ 44:
As for the required example, sometimes it's simpler to do just a small bit of "extra" work:
 
<lang j> ((1 ":@:+ ~."1@index),.' ',.;@~."1@deg2pnt,.' ',.'7.2'8!:2]) _5.62 0 5.62 +/~11.25 * i.33
1 North -5.62 0.00 5.62
2 North by east 5.63 11.25 16.87
Line 50 ⟶ 51:
5 Northeast 39.38 45.00 50.62
6 Northeast by east 50.63 56.25 61.87
7 NortheastEast-eastnortheast 61.88 67.50 73.12
8 East by north 73.13 78.75 84.37
9 East 84.38 90.00 95.62
Line 58 ⟶ 59:
13 Southeast 129.38 135.00 140.62
14 Southeast by south 140.63 146.25 151.87
15 SoutheastSouth-southsoutheast 151.88 157.50 163.12
16 South by east 163.13 168.75 174.37
17 South 174.38 180.00 185.62
Line 66 ⟶ 67:
21 Southwest 219.38 225.00 230.62
22 Southwest by west 230.63 236.25 241.87
23 SouthwestWest-westsouthwest 241.88 247.50 253.12
24 West by south 253.13 258.75 264.37
25 West 264.38 270.00 275.62
Line 74 ⟶ 75:
29 Northwest 309.38 315.00 320.62
30 Northwest by north 320.63 326.25 331.87
31 NorthwestNorth-northnorthwest 331.88 337.50 343.12
32 North by west 343.13 348.75 354.37
1 North 354.38 360.00 365.62</lang>
6,962

edits