]> gitweb.factorcode.org Git - factor.git/commitdiff
Add firstn-unsafe, input<sequence-unsafe
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 27 Apr 2009 02:22:06 +0000 (21:22 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 27 Apr 2009 02:22:06 +0000 (21:22 -0500)
basis/combinators/smart/smart.factor
basis/generalizations/generalizations.factor

index aa7960539cca6f6d66c022b8262911481c0f06d1..9519847810c81d1487ece27d68fcf5d992f7735a 100644 (file)
@@ -18,6 +18,10 @@ MACRO: input<sequence ( quot -- newquot )
     [ infer in>> ] keep
     '[ _ firstn @ ] ;
 
+MACRO: input<sequence-unsafe ( quot -- newquot )
+    [ infer in>> ] keep
+    '[ _ firstn-unsafe @ ] ;
+
 MACRO: reduce-outputs ( quot operation -- newquot )
     [ dup infer out>> 1 [-] ] dip n*quot compose ;
 
index edee44acc67c96511e3eddde255c1a431145f4e6..139b7a528add97756ddd2848585b57fc7368e7fc 100644 (file)
@@ -26,11 +26,14 @@ MACRO: narray ( n -- )
 MACRO: nsum ( n -- )
     1- [ + ] n*quot ;
 
+MACRO: firstn-unsafe ( n -- )
+    [ '[ [ _ ] dip nth-unsafe ] ] map '[ _ cleave ] ;
+
 MACRO: firstn ( n -- )
     dup zero? [ drop [ drop ] ] [
-        [ [ '[ [ _ ] dip nth-unsafe ] ] map ]
-        [ 1- '[ [ _ ] dip bounds-check 2drop ] ]
-        bi prefix '[ _ cleave ]
+        [ 1- swap bounds-check 2drop ]
+        [ firstn-unsafe ]
+        bi-curry '[ _ _ bi ]
     ] if ;
 
 MACRO: npick ( n -- )