Box the compass: Difference between revisions

Added Quackery.
(Added Quackery.)
Line 5,930:
32 North by west 354.37°
1 North 354.38°</pre>
 
=={{header|QBasic}}==
{{works with|QBasic|1.1}}
Line 5,968 ⟶ 5,969:
compasspoint$ = point$(INT(x))
END FUNCTION</syntaxhighlight>
 
=={{header|Quackery}}==
 
<code>switch</code>, <code>case</code> and <code>otherwise</code> are define at [[Metaprogramming#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ tuck space swap of
join
swap split drop echo$ ] is lecho$ ( $ n --> )
 
[ table ] is heading
 
$ "N NbE N-NE NEbN NE NEbE E-NE EbN
E EbS E-SE SEbE SE SEbS S-SE SbE
S SbW S-SW SWbS SW SWbW W-SW WbS
W WbN W-NW NWbW NW NWbN N-NW NbW"
nest$
witheach
[ $ "" swap
witheach
[ [ switch
char N case $ "north"
char E case $ "east"
char S case $ "south"
char W case $ "west"
char b case $ " by "
otherwise $ "-" ]
join ]
' heading put ]
 
[ 360 1 v/ 32 1 v*
1 2 v+ / 32 mod heading ] is degrees->compass$ ( n/d --> $ )
 
$ " 0.0 16.87 16.88 33.75 50.62 50.63
67.5 84.37 84.38 101.25 118.12 118.13
135.0 151.87 151.88 168.75 185.62 185.63
202.5 219.37 219.38 236.25 253.12 253.13
270.0 286.87 286.88 303.75 320.62 320.63
337.5 354.37 354.38"
nest$
witheach
[ i^ 32 mod 1+
dup 10 < if sp
echo sp
dup $->v drop
degrees->compass$ 19 lecho$
echo$ cr ]</syntaxhighlight>
 
{{out}}
 
<pre> 1 north 0.0
2 north by east 16.87
3 north-northeast 16.88
4 northeast by north 33.75
5 northeast 50.62
6 northeast by east 50.63
7 east-northeast 67.5
8 east by north 84.37
9 east 84.38
10 east by south 101.25
11 east-southeast 118.12
12 southeast by east 118.13
13 southeast 135.0
14 southeast by south 151.87
15 south-southeast 151.88
16 south by east 168.75
17 south 185.62
18 south by west 185.63
19 south-southwest 202.5
20 southwest by south 219.37
21 southwest 219.38
22 southwest by west 236.25
23 west-southwest 253.12
24 west by south 253.13
25 west 270.0
26 west by north 286.87
27 west-northwest 286.88
28 northwest by west 303.75
29 northwest 320.62
30 northwest by north 320.63
31 north-northwest 337.5
32 north by west 354.37
1 north 354.38
</pre>
 
=={{header|R}}==
 
1,462

edits