]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.seq: adding "seq" tool.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:37:00 +0000 (14:37 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 1 Apr 2015 21:37:00 +0000 (14:37 -0700)
extra/tools/seq/authors.txt [new file with mode: 0644]
extra/tools/seq/deploy.factor [new file with mode: 0644]
extra/tools/seq/seq.factor [new file with mode: 0644]

diff --git a/extra/tools/seq/authors.txt b/extra/tools/seq/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/tools/seq/deploy.factor b/extra/tools/seq/deploy.factor
new file mode 100644 (file)
index 0000000..92ece2d
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "seq" }
+    { deploy-ui? f }
+    { deploy-c-types? f }
+    { deploy-console? t }
+    { deploy-unicode? f }
+    { "stop-after-last-window?" t }
+    { deploy-io 3 }
+    { deploy-reflection 6 }
+    { deploy-word-props? f }
+    { deploy-math? t }
+    { deploy-threads? t }
+    { deploy-word-defs? f }
+}
diff --git a/extra/tools/seq/seq.factor b/extra/tools/seq/seq.factor
new file mode 100644 (file)
index 0000000..4969a54
--- /dev/null
@@ -0,0 +1,23 @@
+! Copyright (C) 2011 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: combinators command-line io kernel math.order math.parser
+math.ranges namespaces sequences ;
+
+IN: tools.seq
+
+: usage ( -- )
+    "Usage: seq [first [incr]] last" print ;
+
+: seq ( a step b -- )
+    swap <range> [ number>string print ] each ;
+
+: run-seq ( -- )
+    command-line get dup length {
+        { 1 [ first string>number [ 1 1 ] dip seq ] }
+        { 2 [ first2 [ string>number ] bi@ 2dup before? 1 -1 ? swap seq ] }
+        { 3 [ first3 [ string>number ] tri@ seq ] }
+        [ 2drop usage ]
+    } case ;
+
+MAIN: run-seq