]> gitweb.factorcode.org Git - factor.git/commitdiff
generalizations: macro implementation of nrotates / -nrotates
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 17 Jun 2022 06:53:18 +0000 (01:53 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 17 Jun 2022 16:15:14 +0000 (11:15 -0500)
core/generalizations/generalizations.factor
extra/sequences/extras/extras.factor

index 5ead9b12dd03499badf0fcd46f3a841659788427..7876facded88a23ed328061393d93e493ecf6bc1 100644 (file)
@@ -51,11 +51,11 @@ MACRO: -nrot ( n -- quot )
 : ndip ( n -- )
     [ [ dip ] curry ] swap call-n call ; inline
 
-: nrotates ( n depth -- quot )
-    '[ _ [ _ nrot ] times ] call ; inline
+MACRO: nrotates ( n depth -- quot )
+    '[ [ _ nrot ] ] replicate concat ;
 
-: -nrotates ( n depth -- quot )
-    '[ _ [ _ -nrot ] times ] call ; inline
+MACRO: -nrotates ( n depth -- quot )
+    '[ [ _ -nrot ] ] replicate concat ;
 
 : ndrop ( n -- )
     [ drop ] swap call-n ; inline
index 7e46b24445b6f379296d1ad651e67a8ed8438056..b9443bca8d20b69c797079e2a3c6e190754d5a08 100644 (file)
@@ -704,8 +704,7 @@ PRIVATE>
 : find-pred-loop ( ... i n seq quot: ( ... elt -- ... calc ? ) -- ... calc/f i/f elt/f )
     2pick < [
         [ nipd call ] 4keep
-        ! 3 7 nrotates ! stack checker does not like this
-        7 nrot 7 nrot 7 nrot
+        3 7 nrotates
         [ [ 3drop ] 2dip rot ]
         [ 2drop [ 1 + ] 3dip find-pred-loop ] if
     ] [