Skip to main content

Questions tagged [generator]

A generator is a generalization of a subroutine, primarily used to simplify the writing of iterators. The yield statement in a generator does not specify a co-routine to jump to, but rather passes a value back to a parent routine.

2 votes
0 answers
80 views

This is a follow-up question for A recursive_minmax Template Function Implementation in C++ and A recursive_flatten_view Template Function Implementation in C++. The ...
JimmyHu's user avatar
  • 7,575
2 votes
1 answer
114 views

I know this is not necessarily a problem question but more of a style question. I understand that it doesn't have to be pretty for the most part. In general, context managers are used for mutexing, ...
georgwalker45's user avatar
4 votes
3 answers
193 views

I'm learning Rust by solving ProjectEuler problems. To this end, I am trying to port a solution to problem 88 (link) in Python that heavily relies on generators to Rust (which doesn't have generators)....
Bram's user avatar
  • 93
2 votes
1 answer
216 views

The goal here is to pull an item from an array and when the array ends - to start over - and allow you to pull items infinitely as needed. We don't use PHP that much, so please let us know how we can ...
sheriffderek's user avatar
6 votes
1 answer
2k views

An app has a feature that's much like any calendar application (like the Outlook calendar for example). Consequently, I need to do a lot of date logic. I wrote a class with date calculation methods ...
user2190492's user avatar
5 votes
0 answers
225 views

Inspired by a blog I read, I made a LazyList class that can wrap an iterable (list, generator etc.) and turn it into a ...
Greedo's user avatar
  • 2,635
3 votes
2 answers
105 views

I found I need to loop through a list to create a brute force algorithm. Therefore, I decided to make a library, but to generalize the result by using a generator. There are three cases which is every ...
Akash Patel's user avatar
5 votes
1 answer
144 views

The python code simulates an environment of an X number of persons with an Y number of places they can go to, puts the persons randomly in the places and calculates how many persons get infected, die ...
R0Best's user avatar
  • 75
7 votes
4 answers
878 views

I wrote a short function to iterate over a list starting at a given index, then flipping back and forth between left and right values. ...
Antyos's user avatar
  • 189
3 votes
2 answers
530 views

Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. The following variables contain ...
RacketeerHaskeller's user avatar
6 votes
2 answers
431 views

Hello everyone! In this task I had to create docstring generator. I'm just wondering how you see this problem, I have to "take data" from the dictionary ...
KermitTheFrog's user avatar
1 vote
2 answers
609 views

The ideas are When multiple async calls are made, to be able to start consuming from the first resolving one regardless in what order the promises are fired. To construct a modern emitter of async ...
Redu's user avatar
  • 946
6 votes
1 answer
6k views

I am processing an unknown "length" of generator object. I have to keep things "lazy" because of memory management. The processing is compute heavy, so writing it multiproc style ...
Potter A's user avatar
2 votes
1 answer
103 views

I'm iterating through a list to generate calendars, the issue is each generator function has the same this.addToCalendar() function. I'd like to know how I could ...
Bonteq's user avatar
  • 153
1 vote
2 answers
116 views

This is from a leetcode question I am working on. The problem is the following: create an algorithm that works in the the following fashion: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]] the ...
lkilgoretrout's user avatar

15 30 50 per page
1
2 3 4 5
9