September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,6 +1,6 @@
|
|||
Avast me hearties!
|
||||
|
||||
There be many a [http://www.talklikeapirate.com/howto.html land lubber] that knows [http://oxforddictionaries.com/view/entry/m_en_gb0550020#m_en_gb0550020 naught] of the pirate ways and gives direction by degree!
|
||||
There be many a [http://talklikeapirate.com/wordpress/how-to/ land lubber] that knows [https://dictionary.cambridge.org/dictionary/english/naught naught] of the pirate ways and gives direction by degree!
|
||||
They know not how to [[wp:Boxing the compass|box the compass]]!
|
||||
|
||||
|
||||
|
|
|
|||
1
Task/Box-the-compass/00META.yaml
Normal file
1
Task/Box-the-compass/00META.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
--- {}
|
||||
69
Task/Box-the-compass/LLVM/box-the-compass.llvm
Normal file
69
Task/Box-the-compass/LLVM/box-the-compass.llvm
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
; This is not strictly LLVM, as it uses the C library function "printf".
|
||||
; LLVM does not provide a way to print values, so the alternative would be
|
||||
; to just load the string into memory, and that would be boring.
|
||||
|
||||
; Additional comments have been inserted, as well as changes made from the output produced by clang such as putting more meaningful labels for the jumps
|
||||
|
||||
;--- The declarations for the external C functions
|
||||
declare i32 @printf(i8*, ...)
|
||||
|
||||
$"COMPASS_STR" = comdat any
|
||||
$"OUTPUT_STR" = comdat any
|
||||
|
||||
@main.degrees = private unnamed_addr constant [33 x double] [double 0.000000e+00, double 1.687000e+01, double 1.688000e+01, double 3.375000e+01, double 5.062000e+01, double 5.063000e+01, double 6.750000e+01, double 8.437000e+01, double 0x40551851EB851EB8, double 1.012500e+02, double 1.181200e+02, double 1.181300e+02, double 1.350000e+02, double 1.518700e+02, double 1.518800e+02, double 1.687500e+02, double 1.856200e+02, double 1.856300e+02, double 2.025000e+02, double 2.193700e+02, double 2.193800e+02, double 2.362500e+02, double 2.531200e+02, double 2.531300e+02, double 2.700000e+02, double 2.868700e+02, double 2.868800e+02, double 3.037500e+02, double 3.206200e+02, double 3.206300e+02, double 3.375000e+02, double 3.543700e+02, double 3.543800e+02], align 16
|
||||
@"COMPASS_STR" = linkonce_odr unnamed_addr constant [727 x i8] c"North North by east North-northeast Northeast by north Northeast Northeast by east East-northeast East by north East East by south East-southeast Southeast by east Southeast Southeast by south South-southeast South by east South South by west South-southwest Southwest by south Southwest Southwest by west West-southwest West by south West West by north West-northwest Northwest by west Northwest Northwest by north North-northwest North by west North \00", comdat, align 1
|
||||
@"OUTPUT_STR" = linkonce_odr unnamed_addr constant [19 x i8] c"%2d %.22s %6.2f\0A\00", comdat, align 1
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define i32 @main() #0 {
|
||||
%1 = alloca i32, align 4 ;-- allocate i
|
||||
%2 = alloca i32, align 4 ;-- allocate j
|
||||
%3 = alloca [33 x double], align 16 ;-- allocate degrees
|
||||
%4 = alloca i8*, align 8 ;-- allocate names
|
||||
%5 = bitcast [33 x double]* %3 to i8*
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %5, i8* bitcast ([33 x double]* @main.degrees to i8*), i64 264, i32 16, i1 false)
|
||||
store i8* getelementptr inbounds ([727 x i8], [727 x i8]* @"COMPASS_STR", i32 0, i32 0), i8** %4, align 8
|
||||
store i32 0, i32* %1, align 4 ;-- i = 0
|
||||
br label %loop
|
||||
|
||||
loop:
|
||||
%6 = load i32, i32* %1, align 4 ;-- load i
|
||||
%7 = icmp slt i32 %6, 33 ;-- i < 33
|
||||
br i1 %7, label %loop_body, label %exit
|
||||
|
||||
loop_body:
|
||||
%8 = load i32, i32* %1, align 4 ;-- load i
|
||||
%9 = sext i32 %8 to i64 ;-- sign extend i
|
||||
%10 = getelementptr inbounds [33 x double], [33 x double]* %3, i64 0, i64 %9 ;-- calculate index of degrees[i]
|
||||
%11 = load double, double* %10, align 8 ;-- load degrees[i]
|
||||
%12 = fmul double %11, 3.200000e+01 ;-- degrees[i] * 32
|
||||
%13 = fdiv double %12, 3.600000e+02 ;-- degrees[i] * 32 / 360.0
|
||||
%14 = fadd double 5.000000e-01, %13 ;-- 0.5 + degrees[i] * 32 / 360.0
|
||||
%15 = fptosi double %14 to i32 ;-- convert floating point to integer
|
||||
store i32 %15, i32* %2, align 4 ;-- write result to j
|
||||
|
||||
%16 = load i8*, i8** %4, align 8 ;-- load names
|
||||
%17 = load i32, i32* %2, align 4 ;-- load j
|
||||
%18 = srem i32 %17, 32 ;-- j % 32
|
||||
%19 = mul nsw i32 %18, 22 ;-- (j % 32) * 22
|
||||
%20 = sext i32 %19 to i64 ;-- sign extend the result
|
||||
%21 = getelementptr inbounds i8, i8* %16, i64 %20 ;-- load names at the calculated offset
|
||||
%22 = load i32, i32* %2, align 4 ;-- load j
|
||||
%23 = srem i32 %22, 32 ;-- j % 32
|
||||
%24 = add nsw i32 %23, 1 ;-- (j % 32) + 1
|
||||
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @"OUTPUT_STR", i32 0, i32 0), i32 %24, i8* %21, double %11)
|
||||
|
||||
%26 = load i32, i32* %1, align 4 ;-- load i
|
||||
%27 = add nsw i32 %26, 1 ;-- increment i
|
||||
store i32 %27, i32* %1, align 4 ;-- store i
|
||||
br label %loop
|
||||
|
||||
exit:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
|
||||
|
||||
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
attributes #1 = { argmemonly nounwind }
|
||||
15
Task/Box-the-compass/Phix/box-the-compass-2.phix
Normal file
15
Task/Box-the-compass/Phix/box-the-compass-2.phix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
constant compass_points = { "North", "North by east", "North-northeast", "Northeast by north",
|
||||
"Northeast", "Northeast by east", "East-northeast", "East by north",
|
||||
"East", "East by south", "East-southeast", "Southeast by east",
|
||||
"Southeast", "Southeast by south", "South-southeast", "South by east",
|
||||
"South", "South by west", "South-southwest", "Southwest by south",
|
||||
"Southwest", "Southwest by west", "West-southwest", "West by south",
|
||||
"West", "West by north", "West-northwest", "Northwest by west",
|
||||
"Northwest", "Northwest by north", "North-northwest", "North by west"},
|
||||
test_points = { 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}
|
||||
for i=1 to length(test_points) do
|
||||
integer compass_point = remainder(floor(test_points[i]*32/360+0.5),32)+1
|
||||
printf(1, "%2d %-22s %6.2f\n", {compass_point, compass_points[compass_point], test_points[i]})
|
||||
end for
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*REXX program "boxes the compass" [from degree (º) headings ───► a 32 point set]. */
|
||||
parse arg $ /*allow a º heading to be specified. */
|
||||
parse arg $ /*allow º headings to be specified.*/
|
||||
if $='' then $= 0 16.87 16.88 33.75 50.62 50.63 67.5 84.37 84.38 101.25 118.12 118.13 ,
|
||||
135 151.87 151.88 168.75 185.62 185.63 202.5 219.37 219.38 236.25 ,
|
||||
253.12 253.13 270 286.87 286.88 303.75 320.62 320.63 337.5 354.37 354.38
|
||||
|
|
@ -7,7 +7,7 @@ if $='' then $= 0 16.87 16.88 33.75 50.62 50.63 67.5 84.37 84.38 101.25 118.12
|
|||
@pts= '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"
|
||||
|
||||
#=words(@pts) + 1 /*#: used for integer ÷ remainder (//)*/
|
||||
#= words(@pts) + 1 /*#: used for integer ÷ remainder (//)*/
|
||||
dirs= 'north south east west' /*define cardinal compass directions. */
|
||||
/* [↓] choose a glyph for degree (°).*/
|
||||
if 4=='f4'x then degSym= "a1"x /*is this system an EBCDIC system? */
|
||||
|
|
@ -15,15 +15,15 @@ if 4=='f4'x then degSym= "a1"x /*is this system an EBCDIC sy
|
|||
/*──────────────────────────── f8 vs a7*/
|
||||
say right(degSym'heading', 30) center("compass heading", 20)
|
||||
say right( '════════', 30) copies( "═", 20)
|
||||
|
||||
do j=1 for words($); x=word($, j) /*obtain one of the degree headings. */
|
||||
say right(format(x, , 2)degSym, 30-1) ' ' boxHeading(x)
|
||||
end /*j*/
|
||||
pad= ' ' /*used to interject a blank for output.*/
|
||||
do j=1 for words($); x= word($, j) /*obtain one of the degree headings. */
|
||||
say right( format(x, , 2)degSym, 30-1) pad boxHeading(x)
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
boxHeading: y=arg(1)//360; if y<0 then y=360 - y /*normalize heading within unit circle.*/
|
||||
z=word(@pts, trunc(max(1, (y/11.25+1.5) // #))) /*convert degrees─►heading*/
|
||||
do k=1 for words(dirs); d=word(dirs, k)
|
||||
z=changestr( left(d,1), z, d)
|
||||
boxHeading: y= arg(1)//360; if y<0 then y=360-y /*normalize heading within unit circle.*/
|
||||
z= word(@pts, trunc(max(1, (y/11.25 +1.5) // #))) /*convert degrees─►heading*/
|
||||
do k=1 for words(dirs); d= word(dirs, k)
|
||||
z=changestr( left(d, 1), z, d)
|
||||
end /*k*/ /* [↑] old, haystack, new*/
|
||||
return changestr('b', z, " by ") /*expand "b" ──► " by " */
|
||||
return changestr('b', z, " by ") /*expand "b" ───► " by ".*/
|
||||
|
|
|
|||
24
Task/Box-the-compass/Ruby/box-the-compass.rb
Normal file
24
Task/Box-the-compass/Ruby/box-the-compass.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Headings = %w(north east south west north).each_cons(2).flat_map do |a, b|
|
||||
[a,
|
||||
"#{a} by #{b}",
|
||||
"#{a}-#{a}#{b}",
|
||||
"#{a}#{b} by #{a}",
|
||||
"#{a}#{b}",
|
||||
"#{a}#{b} by #{b}",
|
||||
"#{b}-#{a}#{b}",
|
||||
"#{b} by #{a}"]
|
||||
end
|
||||
Headings.prepend nil
|
||||
|
||||
def heading(degrees)
|
||||
i = degrees.quo(360).*(32).round.%(32).+(1)
|
||||
[i, Headings[i]]
|
||||
end
|
||||
|
||||
# an array of angles, in degrees
|
||||
angles = (0..32).map { |i| i * 11.25 + [0, 5.62, -5.62][i % 3] }
|
||||
|
||||
angles.each do |degrees|
|
||||
index, name = heading degrees
|
||||
printf "%2d %20s %6.2f\n", index, name.center(20), degrees
|
||||
end
|
||||
40
Task/Box-the-compass/Rust/box-the-compass.rust
Normal file
40
Task/Box-the-compass/Rust/box-the-compass.rust
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
fn expand(cp: &str) -> String {
|
||||
let mut out = String::new();
|
||||
for c in cp.chars() {
|
||||
out.push_str(match c {
|
||||
'N' => "north",
|
||||
'E' => "east",
|
||||
'S' => "south",
|
||||
'W' => "west",
|
||||
'b' => " by ",
|
||||
_ => "-",
|
||||
});
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cp = [
|
||||
"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"
|
||||
];
|
||||
println!("Index Degrees Compass point");
|
||||
println!("----- ------- -------------");
|
||||
for i in 0..=32 {
|
||||
let index = i % 32;
|
||||
let heading = i as f32 * 11.25
|
||||
+ match i % 3 {
|
||||
1 => 5.62,
|
||||
2 => -5.62,
|
||||
_ => 0.0,
|
||||
};
|
||||
println!(
|
||||
"{:2} {:6.2} {}",
|
||||
index + 1,
|
||||
heading,
|
||||
expand(cp[index])
|
||||
);
|
||||
}
|
||||
}
|
||||
34
Task/Box-the-compass/VBA/box-the-compass.vba
Normal file
34
Task/Box-the-compass/VBA/box-the-compass.vba
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Public Sub box_the_compass()
|
||||
Dim compass_point As Integer
|
||||
Dim compass_points_all As New Collection
|
||||
Dim test_points_all As New Collection
|
||||
Dim compass_points(8) As Variant
|
||||
Dim test_points(3) As Variant
|
||||
compass_points(1) = [{ "North", "North by east", "North-northeast", "Northeast by north"}]
|
||||
compass_points(2) = [{ "Northeast", "Northeast by east", "East-northeast", "East by north"}]
|
||||
compass_points(3) = [{ "East", "East by south", "East-southeast", "Southeast by east"}]
|
||||
compass_points(4) = [{ "Southeast", "Southeast by south", "South-southeast", "South by east"}]
|
||||
compass_points(5) = [{ "South", "South by west", "South-southwest", "Southwest by south"}]
|
||||
compass_points(6) = [{ "Southwest", "Southwest by west", "West-southwest", "West by south"}]
|
||||
compass_points(7) = [{ "West", "West by north", "West-northwest", "Northwest by west"}]
|
||||
compass_points(8) = [{ "Northwest", "Northwest by north", "North-northwest", "North by west"}]
|
||||
test_points(1) = [{ 0.0, 16.87, 16.88, 33.75, 50.62, 50.63, 67.5, 84.37, 84.38, 101.25, 118.12}]
|
||||
test_points(2) = [{ 118.13, 135.0, 151.87, 151.88, 168.75, 185.62, 185.63, 202.5, 219.37, 219.38, 236.25}]
|
||||
test_points(3) = [{ 253.12, 253.13, 270.0, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, 354.37, 354.38}]
|
||||
For i = 1 To 3
|
||||
For Each t In test_points(i)
|
||||
test_points_all.Add t
|
||||
Next t
|
||||
Next i
|
||||
For i = 1 To 8
|
||||
For Each c In compass_points(i)
|
||||
compass_points_all.Add c
|
||||
Next c
|
||||
Next i
|
||||
For i = 1 To test_points_all.Count
|
||||
compass_point = (WorksheetFunction.Floor(test_points_all(i) * 32 / 360 + 0.5, 1) Mod 32) + 1
|
||||
Debug.Print Format(compass_point, "@@"); " "; compass_points_all(compass_point);
|
||||
Debug.Print String$(20 - Len(compass_points_all(compass_point)), " ");
|
||||
Debug.Print test_points_all(i)
|
||||
Next i
|
||||
End Sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue