Double for loops

2020-10-12 Thread pietroppeter
or maybe you want to loop over the tail of the sequences. here is this option compared with @araq's way in a simple example ([playground](https://play.nim-lang.org/#ix=2Auy)): var seq1 = @[ 1, 2, 3 ] seq2 = @[ 1, 2, 3, 4, 5, 6 ] for index in countdown(min(se

Double for loops

2020-10-12 Thread cblake
It sounds like you want a generalization of [sequtils.zip](https://nim-lang.org/docs/sequtils.html#zip%2C%2C) (perhaps that takes a closure iterator that could go backwards like your example and metadata like expected iteration ranges). In Nim nothing stops you from just writing that and using

Double for loops

2020-10-12 Thread Araq
Sometimes a tiny amount of math does the trick: var seq1 = @[ #[First seq's content]# ] seq2 = @[ #[Second seq's content]# ] for index in countdown(min(seq1.len, seq2.len)-1, 0): echo(seq1[index] + seq2[index]) Run

Double for loops

2020-10-12 Thread inventormatt
I believe what you are look for is zip which can be found in sequtils . it only works for two openarrays at a time but it should do what you are asking for.

Double for loops

2020-10-12 Thread archnim
Hello world. I was trying this morning, to loop on two seqs at the same time, but in a reverse order. For example: var seq1 = @[ #[First seq's content]# ] seq2 = @[ #[Second seq's content]# ] for index in countdown(seq1.len, 0): echo (seq1[index] + se