this is kind of like an optional chained operation.
! Copyright (C) 2013 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators.extras io.files kernel math sequences
-tools.test ;
+splitting tools.test ;
{ "a b" }
[ "a" "b" [ " " glue ] once ] unit-test
[ f ]
} cond*
] unit-test
+
+{ f } [ f { } ?call ] unit-test
+{ 5 } [
+ "hello factor!" { [ " " split ] [ first ] [ length ] } ?call
+] unit-test
[ dup callable? [ drop t ] [ first call ] if ] map-find
[ dup callable? [ nip call ] [ second call ] if ]
[ no-cond ] if* ;
+
+MACRO: ?call ( quot -- quot )
+ <reversed> [ ] [ swap '[ [ @ @ ] [ f ] if* ] ] reduce ;