parse-visibility ( str -- str' )


Vocabulary
metar.private

Inputs
stran object


Outputs
str'an object


Definition


: parse-visibility ( str -- str' )
"SM" ?tail [
dup first {
{ 77 [ rest "less than " ] }
{ 80 [ rest "more than " ] }
[ drop "" ]
} case swap 32 over index [ " " "+" replace ] when
string>number "%s%s statute miles" sprintf
] [
4 cut [
string>number {
{ [ dup 800 < ] [ "%dm" sprintf ] }
{ [ dup 5000 < ] [ 1000 /f "%.1fkm" sprintf ] }
{ [ dup 9999 < ] [ 1000 /f "%dkm" sprintf ] }
[ drop "more than 10km" ]
} cond
] dip [
[
H{
{ 83 "south" }
{ 69 "east" }
{ 78 "north" }
{ 87 "west" }
} at
] { } map-as unclip-last [ "-" join ] dip append
" " glue
] unless-empty
] if ;