Category "iterator"

How to iterate over multiple datasets in TensorFlow 2

I use TensorFlow 2.2.0. In my data pipeline, I use multiple datasets to train a neural net. Something like: # these are all tf.data.Dataset objects: paired_data

How to replace make_one_shot_iterator () from google machine learning crash course

I am following the Google Machine Learning Intensive Course. But it uses version 1.x of TensorFlow, so I was planning to change the exercises to be able to run

How to replace make_one_shot_iterator () from google machine learning crash course

I am following the Google Machine Learning Intensive Course. But it uses version 1.x of TensorFlow, so I was planning to change the exercises to be able to run

zip_longest for the left list always

I know about the zip function (which will zip according to the shortest list) and zip_longest (which will zip according to the longest list), but how would I zi

Rust: additional trait bounds in conjunction with higher-ranked lifetime bounds

I want trait implementations in Rust to be able to return arbitrary iterators (of specific item type) that may reference the original object with a lifetime 'a

Is the File-Object iterator "broken?"

According to the documentation: Once an iterator’s __next__() method raises StopIteration, it must continue to do so on subsequent calls. Implementa

Can you use an if/else inside a .filter() / Is there any other way?

TASK: There is an array of words called overusedWords. These are words overused in this story. You want to let the user of your program know how many times the

How to return an iterator from a function and use it?

I'm trying to teach myself Rust by working on a little calendar project. Here I'm trying to generate a list of dates spanning three whole months around a given

String iterator in swift

I try to create an iterator for string processing in swift that will return every time the next chracter. But with no luck. (The final goal is to write a parser

Is an iterator in C++ a pointer?

Is an iterator in C++ a pointer? The reason I ask is that it seems like nobody completely understands what an iterator is. It's just a "thing" or a "value" they

How to take first element from iterator/generator and put it back in Python?

I would like to take first element from iterator, analyse it, then put it back and work with iterator as if it was not touched. For now I wrote: def prepend_i

Why can't I iterate twice over the same data?

Why can't I iterate twice over the same iterator? # data is an iterator. for row in data: print("doing this one time") for row in data: print("doing t

How to skip the first item(s) of an iterator in Rust?

When iterating over arguments (for example) thats the most straightforward way to skip the first N elements? eg: use std::env; fn main() { for arg in env

How to convert a nested for of loop into a custom iterator?

I have the following code: function* getPossibleCollidersWith(shape) { for (let square of retrieve(shape)) { for (let neighbor of square) { yield ne

How to make a C++ class iterable from Python using SWIG?

I have a C++ class Collection that manages a std::vector<Element> (a private member of the class). From C++ I can iterate through the vector using the b

Iterator for custom class in Python 3

I'm trying to port a custom class from Python 2 to Python 3. I can't find the right syntax to port the iterator for the class. Here is a MVCE of the real class

how to increment the iterator from inside for loop in python 3?

for i in range (0, 81): output = send command while True: last_byte = last_byte - offset if last_byte > offset: output = send comm

Is it possible to split a vector into groups of 10 with iterators?

I have let my_vec = (0..25).collect::<Vec<_>>() and I would like to split my_vec into iterators of groups of 10: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; [1

Iterate through a C++ Vector using a 'for' loop

I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the fi

Iterate an iterator by chunks (of n) in Python?

Can you think of a nice way (maybe with itertools) to split an iterator into chunks of given size? Therefore l=[1,2,3,4,5,6,7] with chunks(l,3) becomes an iter