From: Doug Coleman Date: Fri, 17 Jun 2022 06:53:18 +0000 (-0500) Subject: generalizations: macro implementation of nrotates / -nrotates X-Git-Tag: 0.99~1387 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=f42e52aeb7df24c235888bf77d7718063943044f generalizations: macro implementation of nrotates / -nrotates --- diff --git a/core/generalizations/generalizations.factor b/core/generalizations/generalizations.factor index 5ead9b12dd..7876facded 100644 --- a/core/generalizations/generalizations.factor +++ b/core/generalizations/generalizations.factor @@ -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 diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor index 7e46b24445..b9443bca8d 100644 --- a/extra/sequences/extras/extras.factor +++ b/extra/sequences/extras/extras.factor @@ -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 ] [