]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/combinators/short-circuit/smart/smart.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / basis / combinators / short-circuit / smart / smart.factor
index 2cef957a6f5ea5f7574daec8e9cd9953717265c3..7264a07917a1867fd933efc750f96ec5240741f5 100644 (file)
@@ -1,11 +1,18 @@
+USING: kernel sequences math stack-checker effects accessors
+macros fry combinators.short-circuit ;
+IN: combinators.short-circuit.smart
 
-USING: kernel sequences math inference accessors macros
-       combinators.short-circuit ;
+<PRIVATE
 
-IN: combinators.short-circuit.smart
+ERROR: cannot-determine-arity ;
+
+: arity ( quots -- n )
+    first infer
+    dup terminated?>> [ cannot-determine-arity ] when
+    effect-height neg 1 + ;
+
+PRIVATE>
 
-MACRO: && ( quots -- quot )
-  dup first infer [ in>> ] [ out>> ] bi - 1+ n&&-rewrite ;
+MACRO: && ( quots -- quot ) dup arity '[ _ _ n&& ] ;
 
-MACRO: || ( quots -- quot )
-  dup first infer [ in>> ] [ out>> ] bi - 1+ n||-rewrite ;
+MACRO: || ( quots -- quot ) dup arity '[ _ _ n|| ] ;