loops

How would I put a pause in a .forEach interation

依然范特西╮ 提交于 2020-05-17 11:26:30
问题 I am attempting to put in a pause between a forEach loop for a list. I would have thought the timeout would cause a pause for the loop but it just seems to start 3 timers all at once. (In very quick succession.) startTimeout(int seconds) async { print('Timer Being called now'); var duration = Duration(seconds: seconds); Timer(duration, doSomething()); } startDelayedWordPrint() { List<String> testList = ['sfs','sdfsdf', 'sfdsf']; testList.forEach((value) async { await startTimeout(30000);

WPF. Pattern animation class

家住魔仙堡 提交于 2020-05-17 08:50:48
问题 [I created a DrawingLine animation class to draw patterns. The constructor starts the process of creating and animating lines: internal DrawingLine(double x, double y, int _thickness, Brush _brush, Canvas _canvas) At the end of the animation, this method generates a new line: void CreateNewLine(object sender, EventArgs e) { Line newLine = new Line(); switch (lines.Count % 2 == 0) { case true: { if (lines.Count < 18) { newLine.X1 = 0; newLine.Y1 = 180 - offset; newLine.X2 = 0; newLine.Y2 = 180

WPF. Pattern animation class

帅比萌擦擦* 提交于 2020-05-17 08:50:06
问题 [I created a DrawingLine animation class to draw patterns. The constructor starts the process of creating and animating lines: internal DrawingLine(double x, double y, int _thickness, Brush _brush, Canvas _canvas) At the end of the animation, this method generates a new line: void CreateNewLine(object sender, EventArgs e) { Line newLine = new Line(); switch (lines.Count % 2 == 0) { case true: { if (lines.Count < 18) { newLine.X1 = 0; newLine.Y1 = 180 - offset; newLine.X2 = 0; newLine.Y2 = 180

Stuck on infinite loop

江枫思渺然 提交于 2020-05-17 08:21:06
问题 noob programmer here. Taking my first CS class in college and making first post on here so excuse me if the info i provide is not sufficient in advanced. Still trying to figure out loops. Seem to get it but once there is loops within loops or if statements inside loops, I get thrown off and have no idea on how to proceed. For my assignment, I need the following to occur. Would you like to process all the records in the file? (y/n) W Please enter either y or n. Would you like to process all

Run functions for each item on python list separately and append results retrieved from functions to a new list

最后都变了- 提交于 2020-05-17 07:42:54
问题 I'm looking for a way to pass separately each ID from 'email' list as a string to my functions and retrieve 'customerId' and save it to a 'newList' for each item on email list. my code: email = ['733867', '7338704'] newList = [] for x in email: def get_email_details(email, token, userId): headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'token': token, 'userId': userId} endpoint = 'request/' + email + '/details' return requests.get(url = HOST + endpoint, headers =

Loop through, open, perform SendKeys on pdf files in one folder

一曲冷凌霜 提交于 2020-05-17 07:26:23
问题 Sub Password() 'Loop through all files in a folder Dim fileName As Variant fileName = Dir("C:\State_K-1_Info\Password\*.pdf") Do While fileName <> "" CreateObject("Shell.Application").Open ("C:\State_K-1_Info\Password\001.pdf") Application.Wait Now + 0.00005 'Insert the actions to be performed on each file 'This example will print the file name to the immediate window Application.SendKeys "{Tab}", True Application.SendKeys "^(s)", True Application.SendKeys "%{F4}", True 'Set the fileName to

Create new object by using two others using map function

陌路散爱 提交于 2020-05-17 07:08:05
问题 Considering these two objects : struct Product { let id: Int let title: String let price: Int let categoryId: Int } struct Category { let id: Int let name: String } I created also those two data arrays : let products = [ Product(id: 1, title: "snake", price: 20, categoryId: 1), Product(id: 2, title: "soap", price: 20, categoryId: 2), Product(id: 3, title: "cream", price: 20, categoryId: 3), Product(id: 4, title: "dog", price: 20, categoryId: 1), Product(id: 5, title: "car", price: 20,

Node.js RangeError: Maximum call stack size exceeded

蓝咒 提交于 2020-05-17 07:01:06
问题 I am trying to generate all possible combination of a name from my array productsDeduped and then store the generated combination as productTags array. Here is my code: //function to generate all possible combinations function getCombinations(array) { var i, result = []; for (i = 0; i < array.length; i++) { result.push( array[i], ...getCombinations(array.filter((_, j) => i !== j)).map(v => array[i] + " " + v) ); } return result; } for (var i = 0; i < arrLength; i++) { var productNameStrings =

Stylus: Creating mixins with loop results in “override” issue?

醉酒当歌 提交于 2020-05-17 06:07:22
问题 I have the following JSON-file: { "Primary": { "mixin": "primary", "color": "red" }, "Secondary": { "mixin": "secondary", "color": "blue" } } ...that I want to parse and dynamically create mixins off of it. Inspired by https://stackoverflow.com/a/35127312/2000741 I tried the following: colors = json('./colors.json', { hash: true }) for entry in colors mixin = scale[entry]["mixin"] value = scale[entry]["color"] // FIXME: Hack to cast mixin-name to string -> is there a better way? define("" +

Merging objects to obtain the average value in arrays

拈花ヽ惹草 提交于 2020-05-17 06:05:58
问题 I'm trying to obtain an average value for scores arrays and leave other values from the first object. I can't manage how to loop through the objects to achieve expected output. const bigArr = [ { bigDummyData: "string0", examples: [ { smallDD: "string00", scores: [1, 1, 5] }, { smallDD: "string01", scores: [2, 2, 4] }, { smallDD: "string02", scores: [2, 2, 6] }, ], }, { bigDummyData: "string1", examples: [ { smallDD: "string10", scores: [3, 3, 3] }, { smallDD: "string11", scores: [2, 2, 2] },