From cfc3381cabd9de8f82e0f1c519a52efdf5589dd9 Mon Sep 17 00:00:00 2001 From: James Cash Date: Tue, 3 Jun 2008 01:27:06 -0400 Subject: [PATCH] Moving extra/lisp/conses to extra/lists --- extra/lisp/conses/summary.txt | 1 - extra/{lisp/conses => lists}/authors.txt | 0 .../conses-docs.factor => lists/lists-docs.factor} | 0 .../conses-tests.factor => lists/lists-tests.factor} | 12 ++++++++++-- .../conses/conses.factor => lists/lists.factor} | 5 ++++- extra/lists/summary.txt | 1 + extra/{lisp/conses => lists}/tags.txt | 1 - 7 files changed, 15 insertions(+), 5 deletions(-) delete mode 100644 extra/lisp/conses/summary.txt rename extra/{lisp/conses => lists}/authors.txt (100%) rename extra/{lisp/conses/conses-docs.factor => lists/lists-docs.factor} (100%) rename extra/{lisp/conses/conses-tests.factor => lists/lists-tests.factor} (52%) rename extra/{lisp/conses/conses.factor => lists/lists.factor} (84%) create mode 100644 extra/lists/summary.txt rename extra/{lisp/conses => lists}/tags.txt (80%) diff --git a/extra/lisp/conses/summary.txt b/extra/lisp/conses/summary.txt deleted file mode 100644 index d69b63b233..0000000000 --- a/extra/lisp/conses/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Cons cell helper functions for extra/lisp diff --git a/extra/lisp/conses/authors.txt b/extra/lists/authors.txt similarity index 100% rename from extra/lisp/conses/authors.txt rename to extra/lists/authors.txt diff --git a/extra/lisp/conses/conses-docs.factor b/extra/lists/lists-docs.factor similarity index 100% rename from extra/lisp/conses/conses-docs.factor rename to extra/lists/lists-docs.factor diff --git a/extra/lisp/conses/conses-tests.factor b/extra/lists/lists-tests.factor similarity index 52% rename from extra/lisp/conses/conses-tests.factor rename to extra/lists/lists-tests.factor index e4288a2e11..41f2d1d356 100644 --- a/extra/lisp/conses/conses-tests.factor +++ b/extra/lists/lists-tests.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 James Cash ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test lisp.conses math ; +USING: tools.test lists math ; -IN: lisp.conses.tests +IN: lists.tests { { 3 4 5 6 } } [ T{ cons f 1 @@ -10,4 +10,12 @@ IN: lisp.conses.tests T{ cons f 3 T{ cons f 4 T{ cons f f f } } } } } [ 2 + ] map-cons +] unit-test + +{ 10 } [ + T{ cons f 1 + T{ cons f 2 + T{ cons f 3 + T{ cons f 4 + T{ cons f f f } } } } } 0 [ + ] reduce-cons ] unit-test \ No newline at end of file diff --git a/extra/lisp/conses/conses.factor b/extra/lists/lists.factor similarity index 84% rename from extra/lisp/conses/conses.factor rename to extra/lists/lists.factor index c715ac890a..da26580305 100644 --- a/extra/lisp/conses/conses.factor +++ b/extra/lists/lists.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences accessors ; -IN: lisp.conses +IN: lists TUPLE: cons car cdr ; : cons \ cons new ; @@ -26,6 +26,9 @@ TUPLE: cons car cdr ; : map-cons ( cons quot -- seq ) [ { } clone ] 2dip (map-cons) ; +: cons>seq ( cons -- array ) + [ ] map-cons ; + : reduce-cons ( cons identity quot -- result ) pick null? [ drop nip ] [ [ uncons ] 2dip swapd [ call ] keep reduce-cons ] if ; \ No newline at end of file diff --git a/extra/lists/summary.txt b/extra/lists/summary.txt new file mode 100644 index 0000000000..60a18867ab --- /dev/null +++ b/extra/lists/summary.txt @@ -0,0 +1 @@ +Implementation of lisp-style linked lists diff --git a/extra/lisp/conses/tags.txt b/extra/lists/tags.txt similarity index 80% rename from extra/lisp/conses/tags.txt rename to extra/lists/tags.txt index a3f9681acb..e44334b2b5 100644 --- a/extra/lisp/conses/tags.txt +++ b/extra/lists/tags.txt @@ -1,4 +1,3 @@ -lisp cons lists sequences