1,323 questions
1
vote
2
answers
123
views
What is the difference between `for await` and awaiting a promise obtained from a synchronous iterable?
I know there are plenty of resources explaining for await...of, but I don't think I'll ever fully grasp the concept until I see an example that works the exact same way but with more basic syntax.
...
0
votes
1
answer
36
views
How to make TypeScript not complain about Iterator.prototype.take()?
I want to use Iterator.prototype.take() in my code but TypeScript keeps complaining it doesn't exist even though in runtime everything works as expected.
Property 'take' does not exist on type '...
1
vote
1
answer
97
views
Is there an iterator in Python that gives the product but omits permutations of the classes itself?
Assume that I want to assign a color to 5 different balls and have 3 colors r,b and g. I would like to iterate over all these combinations. Preferably I would want to omit combinations that are equal ...
0
votes
0
answers
39
views
How to declare in a *.d.ts file an Iterable of two different types? [duplicate]
This is the javascript function I'm unsuccessfully trying to make vscode show autocomplete suggestions for the returned object:
const profile = (form, validation) =>
Object.defineProperties(
{...
0
votes
0
answers
42
views
How to use an Iterable dataloader for training in pytorch
This is the code i use for creating my dataloaders:
import torch
import os
import pickle
import numpy as np
from torch.utils.data import DataLoader, IterableDataset
from datasets import Dataset, ...
0
votes
0
answers
77
views
When opening a deeplink on ios I get directed to a "route_not_found" screen in Safari after opening the app
I have a react native app that I am trying to get deep links working for. On android they work fine, and on iOS they work fine if and only if the user has fully killed the app. If the user has the ...
1
vote
1
answer
225
views
Angular: TypeError: Type 'any' must have a Symbol.iterator method that returns an iterator
I'm encountering a "TypeError: Type 'any' must have a Symbol.iterator method that returns an iterator" error in my code. I'm trying to create a feature where users can input subtasks into an ...
3
votes
7
answers
190
views
How can one combine iterables keeping only the first element with each index?
Let's say I have a number of iterables:
[[1, 2], [3, 4, 5, 6], [7, 8, 9], [10, 11, 12, 13, 14]]
How can I get only each element that is the first to appear at its index in any of the iterables? In ...
0
votes
0
answers
47
views
Convert asynchronous iterable to non-list iterable
The following code works as expected:
import asyncio
from collections.abc import AsyncIterable, Iterable
# In reality, this is more complicated.
async def create_asynchronous_iterable() -> ...
0
votes
0
answers
103
views
How to use Stream.collect with specific class as suplider
I am a student.
You might think I'm overloading the code with this, unnecessarily, but the goal is just to improve the understanding of the collect method. So all these components that I mention are ...
0
votes
1
answer
52
views
List methods returns Iterable. Does it loses the order after applying a that methods?
I would like to keep the initial order while I apply different transformations to the items.
For example, I have a list that is ordered and I would like to apply a function using map to each element. ...
-1
votes
1
answer
103
views
How to write iterable class with sentinel to use it in find_if?
I have C++ code written around March 2023. It compiled fine back then. Now, I have to make a few changes to it, but it doesn't compile anymore. The used language standard was C++20. I don't remember ...
0
votes
0
answers
54
views
Custom Numeric Iterator Implementation
So I have this structure for my own datatypes:
public class VOID : object
{
public dynamic value;
public dynamic subvalue;
public VOID(dynamic _value = null, dynamic ...
0
votes
0
answers
58
views
'numpy.float64' object is not iterable error when using an array
I am trying to evaluate an ARIMA model.
To evaluate the model, I want to use 5 days into the future as test data.
forecast_data = model_fit.forecast(steps=5)
# Last 5 days of forecast data
...
-1
votes
5
answers
770
views
How can I iterate this list over a loop? I am a beginner and python is my first language
Zybooks Instructions
List data_list contains integers read from input, representing a sequence of data values. For each index i of data_list from 1 through the second-to-last index:
The element at ...
0
votes
1
answer
56
views
How the builtin Python's next function works as used in the Gunicorn server
The following is the code cross section from gunicorn.workers.sync.SyncWorker class self.handle method:
def handle(self, listener, client, addr):
req = None
try:
if self....
0
votes
0
answers
42
views
I still need help on finishing my trench traversal program to pass all tests but am still at a standstill where it says a variable is not an iterable
This problem has still been nagging at me for weeks, and I've made no further progress. I've got previous code passing tests, and here's that which is still giving me trouble.
// Function to traverse ...
1
vote
1
answer
96
views
Dart: Remove from Iterable until criteria is met
I am having an Iterable<MyClass> where MyClass has an attribute data. Now I want to remove elements from my Iterable starting from the last added item. I want to remove them until the sum of all ...
2
votes
1
answer
152
views
C++ term for an object that can be iterated through begin and end
iterator is the generic word for something that can iterate a collection of objects.
On the other hand, I'm not sure that there is a commonly accepted word in C++ for the collection itself, in ...
0
votes
0
answers
24
views
IterableUtils size() function deletes all elements from the object
I have an API which returns an Iterable object. When I tried logging the same object's size using org.apache.commons.collections4.IterableUtils.size(iterable) fuction, I observed that the this API is ...
0
votes
0
answers
21
views
Create a string field from an iterable string field as it is consumed
I have the following model:
from pydantic import BaseModel
from collections.abc import AsyncIterable
class Message(BaseModel):
content_iterable: AsyncIterable[str]
content: str | None = None
...
0
votes
1
answer
374
views
Kanren Problem in python -> ImportError: cannot import name 'Iterator' from 'collections'
I am learning A.I. with python from Tutorials Point and I reached to the Logic Programming section,
here the program is of "Matching Mathematical expressions", and they consider to import ...
1
vote
0
answers
714
views
Why do I get Uncaught TypeError: e.children is not iterable error when having 2 instances of swiper slider on the same page?
I'm trying to make 2 instances of a Swiper slider, so I can have 2 kinds of sliders on the same page. A video and a review slider.
I'm encountering a warning that says "jQuery.Deferred exception: ...
0
votes
0
answers
42
views
Vector of non-iterable items in Rust [duplicate]
Consider the following code:
let mut centroids: Vec<(f64, f64)> = Vec::new();
centroids.extend((90.0, 0.0));
It produces error 277:
error[E0277]: `({float}, {float})` is not an iterator
...
0
votes
1
answer
49
views
What happens with memory for list literals with range when converted to iterator object?
I'm wondering if CODE 2 requires 41880+ of memory space anyways, since I "created" a list... but perhaps not because I didn't store it in a variable?
In other words, are CODE 1 and CODE 2 ...
1
vote
2
answers
47
views
I'm new to coding and am trying to get the sum of these 'y' values, but nothing I've tried seemed to work
So I'm trying to sum up the 'y' values of this code, so I can use it later on. Everything I've tried so far (a lot) didn't seem to work. And I just don't know how to fix it.
This is my code:
inventory ...
-1
votes
1
answer
60
views
Iterables difference and common elements
Given 2 iterables/lists, the goal is to extract the common and different elements from both lists.
For example, given:
x, y = [1,1,5,2,2,3,4,5,5], [2,3,4,5]
The goal is to achieve:
common = [2,3,4,5]
...
1
vote
2
answers
110
views
Kotlin yield example
I am learning Kotlin and for the love of it, I cannot get the yield/sequence straight. Could someone please correct my code?
fun Sequence<Int>.mapIterable(transform: (Int)->Int) = sequence {
...
1
vote
1
answer
87
views
Enclosing an iterable in a generator expression changes the order that contexts are cleaned up
I have a Python application which has two nested with blocks, one of which occurs inside an object's __iter__ method. I have observed that wrapping the iterable object inside a generator expression ...
0
votes
1
answer
29
views
python 'int' object is not iterable. Please
Code:
liste10=[1,[2,3],[4,5,6,7]]
for i in liste10:
for x in i:
print(i)
Error:
---------------------------------------------------------------------------
TypeError ...
1
vote
1
answer
86
views
Plot iterable classes with Plotly
I'm having some problems with the plot of some iterable classes in Python. The idea is to use plotly to plot lines obtained from the iterator of a class. Here is an example of the class:
class ...
1
vote
0
answers
54
views
Error while compiling typescript in VSCode
I have the following code which I am trying to compile:
function twoSum(nums: number[], target: number): number[] {
let res:number[] = [];
let dict = new Map<number, number>();
for (...
-1
votes
1
answer
31
views
Accessing maximum or minimum nested list element [duplicate]
a = [['a', 20], ['b', 36], ['c', 1], ['d', 8], ['e', 55]]
How can I print out the minimum value or maximum value by using Python built-in functions like min() or max()?
The result would look like ['e'...
0
votes
1
answer
66
views
Trying to Loop and Add things to Iterable Java
I am trying to create a search page that allows you to use multiple terms and values keep having problems on finding a way to keep all the results. It works for one item but when I do multiple it only ...
-2
votes
1
answer
121
views
TypeError: 'int' object is not iterable (map(str, result))
TypeError Traceback (most recent call last)
<ipython-input-10-6eada5f638a8> in <cell line: 8>()
15 result = oddNumbers(l, r)
16
---> 17 ...
0
votes
0
answers
68
views
A problem importing lightkurve python package
I am having a problem importing the lightkurve package due to an error within astropy.
I downloaded the lightkurve 2.4.0 package, and then ran the code "import lightkurve". The import did ...
2
votes
1
answer
699
views
How can I determine if an Iterable will be empty or not after iterating in TypeScript?
How can I differentiate between iterables that become empty after iteration and those that don't, in TypeScript?
type ReusableIterable<T> = Iterable<T> // ?
function iterate(iterable: ...
0
votes
2
answers
72
views
Flutter Error: The argument type 'List<dynamic>' can't be assigned to the parameter type 'Iterable<Future<dynamic>>'
I'm trying multiple request in a controller.
var requests = [];
for(var url in urls){
requests.add(http.get(Uri.parse(url.split(',')[0])));
}
var results = await Future.wait(requests as Iterable<...
-2
votes
1
answer
347
views
I am trying to make a web-application using streamlit and getting error argument of type 'method' is not iterable
So I made a function which i later imported to another file no i am trying to make a web application using stream lit where I want user to upload a data and that data should go through my function and ...
0
votes
1
answer
248
views
Flutter: getting an 'Expected a value of type Iterable<dynamic>, but got one of type `_JsonMap`' error when retrieving JSON data from a URL
Error: Expected a value of type 'Iterable', but got one of type '_JsonMap' Flutter
import 'dart:convert';
import 'package:flutter/material.dart';
import '../data/character_api.dart';
import '../model/...
-1
votes
1
answer
80
views
How does zip and zip_longest work with iterables in python 3.x?
This is my code snippet
from itertools import zip_longest
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
args = [iter(list1)] * 4
zipped = zip_longest(*args, fillvalue=None)
for j in ...
3
votes
1
answer
271
views
How does a JavaScript developer find implementing classes of an interface?
I am learning JavaScript, and I am coming from Java.
A Java developer can easily evaluate the usefulness of an interface, because all known implementing classes are documented. Please click here to ...
0
votes
4
answers
360
views
Adding items from one list to another list of lists
Suppose I have the following lists:
list_1 = [[1,2],[3,4],[5,6],[7,8]]
list_2 = [11,12,13,14]
How can I add items from the second list to each of the items from the first one?
Stated clearly, this is ...
0
votes
2
answers
146
views
Combining Generators to Seat Guests For an Event: Type Error: function object is not iterable
I want to be able to use the generators to assign a table and a seat number with meal selections to each guest. I need to create a generator function that will take in as input the guest's dictionary ...
0
votes
3
answers
351
views
How to make iterable class method?
It's telling me "TypeError: Foo.my_method(...) is not a function or its return value is not async iterable". How to make it so?
class Foo {
constructor() {
return (async () => { ...
2
votes
2
answers
198
views
How can I make an iterable in JavaScript? [duplicate]
I'm trying to understand iterables in JavaScript by creating a range function, but it doesn't work
I'm trying to understand iterables in JavaScript so I created a range function that when I call it, ...
1
vote
1
answer
1k
views
efficient way to convert iterable to list of entity
Whats an efficient way to convert iterable to list of entity?
in below code. last line which collects to list - take ~70seconds for large data set (about 400k)
//mongoDB: reading from collection
...
2
votes
1
answer
1k
views
TypeError: 'float' object is not iterable for dataframe
why it is giving 'float' object is not iterable error? when I put nested loop?
text = []
for i in df['text']:
string = ""
for j in i:
string += j
text.append(string)
...
2
votes
2
answers
141
views
How to map a JavaScript iterable without writing an iteration function?
Some methods in Javascript, for example Map.prototype.values, return an iterable. Without writing a function to iterate through the values, can I map them to something else as per Array.prototype.map?...
1
vote
3
answers
353
views
Use iteration to find a specific enum variant in a collection
Setup
I have an enum whose variants have struct parameters, along with a vector of the enum:
struct A { x: i64, };
struct B { x: f64, },
enum E {
One(A),
Two(B),
// maybe others
};
fn main() {...