Skip to content

Commit

Permalink
math.combinatorics: simplify find-permutation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Dec 8, 2024
1 parent dcaf7a0 commit 464e938
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions basis/math/combinatorics/combinatorics.factor
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DEFER: next-permutation

<PRIVATE

: <permutation-iota> ( seq -- <iota> )
: <permutation-iota> ( seq -- iota )
length factorial <iota> ; inline

: permutations-quot ( seq quot -- seq quot' )
Expand All @@ -121,8 +121,7 @@ PRIVATE>
permutations-quot all? ; inline

: find-permutation ( ... seq quot: ( ... elt -- ... ? ) -- ... elt/f )
[ permutations-quot find drop ]
[ drop over [ permutation ] [ 2drop f ] if ] 2bi ; inline
'[ _ keep and ] permutations-quot map-find drop ; inline

: reduce-permutations ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
swapd each-permutation ; inline
Expand Down

0 comments on commit 464e938

Please sign in to comment.