From 12d22e593ce08899309eb2f9aba5fe84342f3c7e Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Fri, 4 Jul 2008 15:22:47 -0500
Subject: [PATCH] bake.fry: commas factor

---
 extra/bake/fry/fry.factor | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/extra/bake/fry/fry.factor b/extra/bake/fry/fry.factor
index e5d0813e02..6b069334e6 100644
--- a/extra/bake/fry/fry.factor
+++ b/extra/bake/fry/fry.factor
@@ -1,6 +1,7 @@
 
 USING: kernel combinators arrays vectors quotations sequences splitting
-       parser macros sequences.deep combinators.conditional bake newfx ;
+       parser macros sequences.deep
+       combinators.short-circuit combinators.conditional bake newfx ;
 
 IN: bake.fry
 
@@ -53,28 +54,22 @@ DEFER: shallow-fry
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
+: bakeable? ( obj -- ? ) { [ array? ] [ vector? ] } 1|| ;
+
 : fry-specifier? ( obj -- ? ) { , @ } member-of? ;
 
 : count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ;
 
+: commas ( n -- seq ) , <repetition> ;
+
 : [fry] ( quot -- quot' )
     [
-      {
         {
-          [ callable? ]
-          [ [ count-inputs \ , <repetition> ] [ [fry] ] bi append ]
+          { [ callable? ] [ [ count-inputs commas ] [ [fry]  ] bi append ] }
+          { [ bakeable? ] [ [ count-inputs commas ] [ [bake] ] bi append ] }
+          { [ drop t    ] [ 1quotation                                   ] }
         }
-        {
-          [ array? ]
-          [ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
-        }
-        {
-          [ vector? ]
-          [ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
-        }
-        { [ drop t ] [ 1quotation   ] }
-      }
-        1cond
+      1cond
     ]
   map concat deep-fry ;