]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.extras: add callk
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 19 Aug 2022 04:03:47 +0000 (23:03 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 26 Feb 2023 23:11:03 +0000 (17:11 -0600)
it keeps the quot

extra/combinators/extras/extras.factor

index 36b3f0a6ef520e627a452a0bcee318e4c465617c..162948e6571217ec3276d73ad87b9b5ea23aa1b7 100644 (file)
@@ -6,9 +6,12 @@ quotations sequences sequences.generalizations sequences.private
 sets shuffle stack-checker.transforms system words ;
 IN: combinators.extras
 
+: callk ( ..a quot: ( ..a -- ..b ) -- ..b quot )
+    dup [ call ] dip ; inline
+
 : once ( quot -- ) call ; inline
-: twice ( quot -- ) dup [ call ] dip call ; inline
-: thrice ( quot -- ) dup dup [ call ] 2dip [ call ] dip call ; inline
+: twice ( quot -- ) callk call ; inline
+: thrice ( quot -- ) callk callk call ; inline
 : forever ( quot -- ) [ t ] compose loop ; inline
 
 MACRO: cond-case ( assoc -- quot )