Something similar to 
[https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next](https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next)
 and 
[https://doc.rust-lang.org/std/iter/struct.Peekable.html#method.peek](https://doc.rust-lang.org/std/iter/struct.Peekable.html#method.peek)
    
    
    import utils, strutils
    
    for line in lines open getData "day2":
        for codeStr in split ",":
            let code = parseInt codeStr
            case code:
                of 1:
                    #[
                        let next1 = next()
                        let next2 = next()
                        let next3 = next()
                        # iterator has advanced by 3 now
                    ]#
                of 2:
                    #[
                        let next = peek()
                        # iterator has not advanced forward
                    ]#
                of 99:
                    # ...
                else:
                    quit "Cannot parse instructions"
    
    
    Run

Reply via email to