Three word location: Difference between revisions
m
→{{header|Julia}}: bit twiddles
Thundergnat (talk | contribs) (→{{header|Raku}}: Make word indexing routine user overridable, demo) |
m (→{{header|Julia}}: bit twiddles) |
||
Line 168:
=={{header|Julia}}==
Direct translation from the SymSyn example given by the task creator
<lang julia>
# Three Word Location - convert latitude and longitude to three words
Line 187:
# next 14 bits for word 2 index
# next 14 bits for word 3 index
W1 = (LATLON >> 28) &
W2 = (LATLON >> 14) &
W3 = LATLON &
# fetch each word from word array
Line 241:
end
i = (Int(lat * 10000 + 900000) << 22) | Int(lon * 10000 + 1800000)
return map(x -> arr[x + 1], [(i >> 28) &
end
|