Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsigned version for find_subset #5

Open
MhhhxX opened this issue Jun 7, 2023 · 1 comment
Open

Unsigned version for find_subset #5

MhhhxX opened this issue Jun 7, 2023 · 1 comment

Comments

@MhhhxX
Copy link

MhhhxX commented Jun 7, 2023

Does this crate offer an unsigned version of the find_subset function?

For example a function with a signature like:

fn find_subset(Vec<usize>, usize, usize) -> Vec<Vec<usize>>;

I would need that in my project.

@europeanplaice
Copy link
Owner

I haven't implemented an unsigned version of the find_subset function, but you can introduce an original function like this.

use dpss::dp::find_subset;

fn find_subset_unsigned(vec_usize: Vec<usize>, value: usize, max_length: usize) -> Vec<Vec<usize>>{
    let vec_i32: Vec<i32> = vec_usize.into_iter().map(|x| x as i32).collect();
    
    let vec_vec_i32 = find_subset(vec_i32, value as i32, max_length);
    let vec_vec_usize: Vec<Vec<usize>> = vec_vec_i32
        .into_iter()
        .map(|inner_vec| inner_vec.into_iter().map(|x| x as usize).collect())
        .collect();
    return vec_vec_usize;
}

fn main() {
    let result = find_subset_unsigned(vec![1, 2, 3, 4, 5], 6, 3);
    println!("{:?}", result);
}

Though _find_subsetsfast_only_positive function is implemented internally, it is not publicly available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants