]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.extras: Add twice, thrice words.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 7 Mar 2013 22:11:01 +0000 (14:11 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 9 Mar 2013 00:50:10 +0000 (16:50 -0800)
extra/combinators/extras/authors.txt [new file with mode: 0644]
extra/combinators/extras/extras-tests.factor [new file with mode: 0644]
extra/combinators/extras/extras.factor [new file with mode: 0644]

diff --git a/extra/combinators/extras/authors.txt b/extra/combinators/extras/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/combinators/extras/extras-tests.factor b/extra/combinators/extras/extras-tests.factor
new file mode 100644 (file)
index 0000000..c72b493
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2013 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test combinators.extras sequences ;
+IN: combinators.extras.tests
+
+{ "a b" }
+[ "a" "b" [ " " glue ] once ] unit-test
+
+{ "a b c" }
+[ "a" "b" "c" [ " " glue ] twice ] unit-test
+
+{ "a b c d" }
+[ "a" "b" "c" "d" [ " " glue ] thrice ] unit-test
diff --git a/extra/combinators/extras/extras.factor b/extra/combinators/extras/extras.factor
new file mode 100644 (file)
index 0000000..03025b8
--- /dev/null
@@ -0,0 +1,8 @@
+! Copyright (C) 2013 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel ;
+IN: combinators.extras
+
+: once ( quot -- ) call ; inline
+: twice ( quot -- ) dup [ call ] dip call ; inline
+: thrice ( quot -- ) dup dup [ call ] 2dip [ call ] dip call ; inline