]> gitweb.factorcode.org Git - factor.git/commitdiff
use smart combinator in geo-ip
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 8 Jan 2009 23:53:48 +0000 (17:53 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 8 Jan 2009 23:53:48 +0000 (17:53 -0600)
extra/geo-ip/geo-ip.factor

index c878306d7df4fbb43ffef82a6c9818b0e4aafb75..ad6302ca55b4e7e71a814c4b4153e7031e76b078 100644 (file)
@@ -4,7 +4,7 @@ USING: kernel sequences io.files io.files.temp io.launcher
 io.pathnames io.encodings.ascii io.streams.string http.client
 generalizations combinators math.parser math.vectors
 math.intervals interval-maps memoize csv accessors assocs
-strings math splitting grouping arrays ;
+strings math splitting grouping arrays combinators.smart ;
 IN: geo-ip
 
 : db-path ( -- path ) "IpToCountry.csv" temp-file ;
@@ -20,15 +20,17 @@ IN: geo-ip
 TUPLE: ip-entry from to registry assigned city cntry country ;
 
 : parse-ip-entry ( row -- ip-entry )
-    7 firstn {
-        [ string>number ]
-        [ string>number ]
-        [ ]
-        [ ]
-        [ ]
-        [ ]
-        [ ]
-    } spread ip-entry boa ;
+    [
+        {
+            [ string>number ]
+            [ string>number ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+            [ ]
+        } spread
+    ] input<sequence ip-entry boa ;
 
 MEMO: ip-db ( -- seq )
     download-db ascii file-lines