All fields

“Iterators & Generators” in Information Technology

37 questions across 4 technologies.

Information Technology

37 questions in 4 technologies

#QuestionTechnologyTopicLevel
1How were generators historically used to write asynchronous code before async/await existed? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsAdvanced
2Can you use a for...of loop directly on a generator's return value? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsBeginner
3How do you implement an infinite sequence using a generator, and why is this safe? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsIntermediate
4What makes an object 'iterable' in JavaScript? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsBeginner
5How do you write a basic generator function? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsBeginner
6How does yield pause and resume execution, and what does it return to the caller? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsIntermediate
7How do you delegate from one generator to another using yield*? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsIntermediate
8How do you use generator.throw() and generator.return() to control a running generator externally? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsAdvanced
9How would you implement a custom Symbol.iterator for a tree data structure to enable depth-first traversal with for...of? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsAdvanced
10What's the performance and memory advantage of a generator-based lazy pipeline over building intermediate arrays with map/filter? JavaScript › Iterators & GeneratorsJavaScriptIterators & GeneratorsAdvanced
11How do generators help implement memory efficient data processing pipelines, chaining multiple transformation steps together without ever loading an entire dataset into memory at once? PHP › Generators & IteratorsPHPGenerators & IteratorsAdvanced
12What are the limitations of PHP generators compared to regular arrays, particularly around rewinding and multiple iteration passes? PHP › Generators & IteratorsPHPGenerators & IteratorsAdvanced
13What is a generator in PHP, and how does the yield keyword let a function produce a sequence of values without building an entire array in memory at once? PHP › Generators & IteratorsPHPGenerators & IteratorsBeginner
14What is the Iterator interface in PHP, and how does it relate to how a foreach loop actually works behind the scenes? PHP › Generators & IteratorsPHPGenerators & IteratorsBeginner
15What is the relationship between generators and the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
16What is the IteratorAggregate interface, and how does it provide a simpler alternative to implementing the full Iterator interface directly? PHP › Generators & IteratorsPHPGenerators & IteratorsIntermediate
17How can a generator receive values sent into it during iteration using the send method, enabling two way communication with the calling code? PHP › Generators & IteratorsPHPGenerators & IteratorsIntermediate
18How does yield from let a generator delegate part of its iteration to another generator or an array, and why is this useful? PHP › Generators & IteratorsPHPGenerators & IteratorsIntermediate
19How can generators and iterators help reduce peak memory usage compared to building full lists? Python › Memory Management & Garbage CollectionPythonMemory Management & Garbage CollectionAdvanced
20What is an async iterator? JavaScript › Async Iterators & StreamsJavaScriptAsync Iterators & StreamsBeginner
21How do you write an async generator function? JavaScript › Async Iterators & StreamsJavaScriptAsync Iterators & StreamsIntermediate
22How do you implement a custom iterator by defining __iter__ and __next__? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
23What is a generator function, and how does 'yield' make it different from a regular function? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsBeginner
24What is the difference between an iterable and an iterator in Python? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
25What exception signals the end of iteration, and how does a for-loop use it internally? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
26What does the built-in next() function's optional default argument do? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
27How does the itertools module complement the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
28What is the difference between iter(obj) and using obj directly in a for-loop, in terms of what Python calls internally? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
29How would you implement a custom async iterator class from scratch, without using an async generator function? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
30How does 'yield from' delegate iteration to a sub-generator, and what does it return as its own expression value? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
31What is the difference between __iter__ returning self versus returning a separate iterator object? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
32How would you implement a lazy, chainable iterator pipeline (like filter-then-map) from scratch? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
33What does functools.reduce do, and why is it often discouraged in favor of loops? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
34What is the practical difference between using functools.reduce and a plain for-loop for accumulation? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
35Why can array holes (sparse arrays) behave unexpectedly with iteration methods? JavaScript › Arrays & Array MethodsJavaScriptArrays & Array MethodsAdvanced
36What are functors and monads, at a practical level, and does JavaScript have native support for them? JavaScript › Functional ProgrammingJavaScriptFunctional ProgrammingAdvanced
37What is an async generator, and how does 'for await...of' let you consume asynchronously produced data? Node.js › Async PatternsNode.jsAsync PatternsAdvanced