Coder Social home page Coder Social logo

Comments (5)

kindlychung avatar kindlychung commented on July 19, 2024

!self.phase && a > b || (self.phase && a < b) seems correct to me.

from itertools.

bluss avatar bluss commented on July 19, 2024

It has a quickcheck test here https://github.com/bluss/rust-itertools/blob/master/tests/quick.rs#L306

Can you form a testcase that fails?

from itertools.

kindlychung avatar kindlychung commented on July 19, 2024

I don't know quickcheck well enough at the moment, but check this out:

extern crate itertools;

use itertools::InterleaveShortest;

fn main() {
    let a = vec![1u32, 2u32, 3u32]; 
    let b = vec![1u32, 2u32, 3u32, 4u32, 5u32, 6u32]; 
    let mut i = InterleaveShortest::new(a.into_iter(), b.into_iter());
    let x = i.next(); 
    println!("{:?}", i.size_hint());
}

This prints (4, Some(5)), which in my opinion is not really accurate, I would expect (5, Some(5)).

from itertools.

kindlychung avatar kindlychung commented on July 19, 2024

This produces (5, Some(5)):

        let bound = |a: usize, b: usize| -> Option<usize> {
            use std::cmp::min;
            2usize.checked_mul(min(a, b))
//                .and_then(|lhs| lhs.checked_add(if !self.phase && a > b { 1 } else { 0 }))
                .and_then(|lhs| lhs.checked_add(if  !self.phase && a > b || (self.phase && a < b)  { 1 } else { 0 }))
        };

from itertools.

bluss avatar bluss commented on July 19, 2024

nice, thanks a lot!

from itertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.