fix: create all permutations of depth for tree command
This commit is contained in:
parent
a58da2ffda
commit
28881a4ec5
1 changed files with 6 additions and 8 deletions
|
|
@ -95,14 +95,12 @@ pub fn create_tag_combinations(tags: &[String], depth: usize) -> Vec<Vec<String>
|
|||
|
||||
// Start with existing combinations of length-1
|
||||
for combo in result.iter().filter(|c| c.len() == len - 1) {
|
||||
// Try to add each remaining tag that comes after the last tag in combo
|
||||
if let Some(last) = combo.last() {
|
||||
for tag in tags {
|
||||
if tag > last && !combo.contains(tag) {
|
||||
let mut new_combo = combo.clone();
|
||||
new_combo.push(tag.clone());
|
||||
temp.push(new_combo);
|
||||
}
|
||||
// Try to add each remaining tag
|
||||
for tag in tags {
|
||||
if !combo.contains(tag) {
|
||||
let mut new_combo = combo.clone();
|
||||
new_combo.push(tag.clone());
|
||||
temp.push(new_combo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue