]> gitweb.factorcode.org Git - factor.git/commitdiff
metar: print all-stations.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 26 Oct 2021 19:45:43 +0000 (12:45 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 26 Oct 2021 19:45:43 +0000 (12:45 -0700)
extra/metar/metar.factor

index 9916f4f2131279188f0c9ff067e08ab3f06c7da6..6352404b0f696510d3f344fcd66c416a3a050b7d 100644 (file)
@@ -2,10 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors arrays ascii assocs calendar calendar.format
-combinators command-line continuations csv formatting fry
-grouping http.client io io.encodings.ascii io.files io.styles
-kernel math math.extras math.parser memoize namespaces regexp
-sequences sorting.human splitting strings urls wrap.strings ;
+classes.tuple combinators command-line continuations csv
+formatting fry grouping http.client io io.encodings.ascii
+io.files io.styles kernel math math.extras math.parser memoize
+namespaces regexp sequences sorting.human splitting strings urls
+wrap.strings ;
 
 IN: metar
 
@@ -57,6 +58,21 @@ MEMO: all-stations ( -- seq )
         } cleave <station>
     ] map ;
 
+: all-stations. ( -- )
+    all-stations standard-table-style [
+        [
+            [
+                tuple-slots [
+                    [
+                        [
+                            dup string? [ "%.2f" sprintf ] unless write
+                        ] when*
+                    ] with-cell
+                ] each
+            ] with-row
+        ] each
+    ] tabular-output nl ;
+
 : find-by-cccc ( cccc -- station )
     all-stations swap '[ cccc>> _ = ] find nip ;