From 6a2c0ef83121ebd11c5a233a85319a4adbd9ad53 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 31 Jul 2022 17:30:01 -0700 Subject: [PATCH] math.combinatorics: minor cleanup to next-combination --- basis/math/combinatorics/combinatorics.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/math/combinatorics/combinatorics.factor b/basis/math/combinatorics/combinatorics.factor index b1017ef848..45da55dab8 100644 --- a/basis/math/combinatorics/combinatorics.factor +++ b/basis/math/combinatorics/combinatorics.factor @@ -272,17 +272,17 @@ INSTANCE: combinations immutable-sequence : increment-last ( seq -- ) [ index-of-last [ 1 + ] change-nth-unsafe ] unless-empty ; inline -:: next-combination ( seq n -- seq ) +:: next-combination ( seq n -- ) seq n find-max-index [ 1 [-] seq increment-rest ] [ seq increment-last - ] if* seq ; inline + ] if* ; inline :: combinations-quot ( seq k quot -- seq quot' ) seq length :> n n k nCk k >array seq quot n - '[ drop _ [ _ nths-unsafe @ ] keep _ next-combination drop ] ; inline + '[ drop _ [ _ nths-unsafe @ ] keep _ next-combination ] ; inline PRIVATE> -- 2.34.1