]> gitweb.factorcode.org Git - factor.git/commitdiff
math.primes.factors: support command-line args like factor(1).
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Feb 2017 19:14:24 +0000 (11:14 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Feb 2017 19:14:24 +0000 (11:14 -0800)
basis/math/primes/factors/factors.factor

index 105bd5b976679c9bcdf238357793daaeb090c6e4..045c34a3e0f6e71582588d1e124fc5ef6ea345a9 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2007-2009 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs combinators kernel make math math.functions
-math.primes math.ranges sequences sequences.product sorting
-io math.parser ;
+USING: arrays assocs combinators command-line io kernel make
+math math.functions math.parser math.primes math.ranges
+namespaces sequences sequences.product sorting ;
 IN: math.primes.factors
 
 <PRIVATE
@@ -62,6 +62,10 @@ PRIVATE>
     ] if* ;
 
 : run-unix-factor ( -- )
-    [ readln [ unix-factor t ] [ f ] if* ] loop ;
+    command-line get [
+        [ readln [ unix-factor t ] [ f ] if* ] loop
+    ] [
+        [ unix-factor ] each
+    ] if-empty ;
 
 MAIN: run-unix-factor