for-loop

At which point does `forfiles` enumerate a directory (tree)?

蓝咒 提交于 2020-01-04 23:31:35
问题 The command forfiles is intended to enumerate a directory and apply (a) certain command(s) on each item. With the /S the same can be accomplished for a full directory tree. What happens when the content of the enumerated directory (tree) is changed by the command(s) in the body of the forfiles command? Supposed we have the directory D:\data with the following content: file1.txt file2.txt file3.txt The output of forfiles /P "D:\data" /M "*.txt" /C "cmd /C echo @file" when executed in said

Overloading (c)begin/(c)end

为君一笑 提交于 2020-01-04 21:35:55
问题 I tried to overload (c)begin / (c)end functions for a class so as to be able to call C++11 range-based for loop. It works in most of the cases, but I don't manage to understand and solve one : for (auto const& point : fProjectData->getPoints()){ ... } This line returns error: Error C2662: 'MyCollection<T>::begin' : cannot convert 'this' pointer from 'const MyCollection' to 'MyCollection<T> &' because fProjectData is a pointer to const. If I make it non-const, it does work. I don't understand

How to iterate over cms plugin instances from a page in a Django template?

馋奶兔 提交于 2020-01-04 18:32:13
问题 I want to display a list of YouTube videos and let my user edit this list. I thought of doing it like this: Make a template where this will be displayed. In this template do something like <ul>{% for plugin in page %}<li>plugin</li>{% endfor %}</ul> . Make a youtube_videos placeholder and configure it to be limited to only that type of plugin. But I don't know how to make this iteration over the plugin instances in the current page in the template. I didn't see anything about this in django

How to iterate over cms plugin instances from a page in a Django template?

和自甴很熟 提交于 2020-01-04 18:32:08
问题 I want to display a list of YouTube videos and let my user edit this list. I thought of doing it like this: Make a template where this will be displayed. In this template do something like <ul>{% for plugin in page %}<li>plugin</li>{% endfor %}</ul> . Make a youtube_videos placeholder and configure it to be limited to only that type of plugin. But I don't know how to make this iteration over the plugin instances in the current page in the template. I didn't see anything about this in django

How to get rid of enclosing double-quotes in the expanded `forfiles` variables?

坚强是说给别人听的谎言 提交于 2020-01-04 16:57:34
问题 The forfiles command establishes several variables, indicated by a leading @ , which return data concerning the currently iterated item to the loop body. All the variables related to the path and name of the iterated item return the value enclosed in "" . Those are: @file , @fname , @ext , @path and @relpath . So: how can you get rid of the enclosing double-quotes? For example, the following code returns relative paths to text files in the given root directory: forfiles /P "C:\root" /M "*.txt

Compute a function from a loop to apply it in a list of dataframe

空扰寡人 提交于 2020-01-04 14:35:14
问题 I have a dataframe df structure(list(ID = structure(c(8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 20L, 20L, 20L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 57L, 57L, 62L, 62L, 62L, 70L, 70L, 70L, 70L, 70L, 2L, 2L, 2L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 46L, 46L, 46L, 46L, 60L, 60L,

SyntaxError: Unexpected token { in javascript

微笑、不失礼 提交于 2020-01-04 14:28:26
问题 I am having an issue on my problem where the console is saying SyntaxError: Unexpected token { and I'm not sure where it's coming from. I am a JS newbie, just learning this stuff. Would you mind pointing out where I am going wrong with my brackets please. var myArray = [4, 6, 23, 10, 1, 3]; var arrayAdditon = function (arr) { var largestNumber = arr[0]; var sumTotal; for (var i = 0; i < arr.length; i += 1) { if (arr[i] > largestNumber) { largestNumber = arr[i]; } } for (var i = 0; i < arr

Run 3 variables at once in a python for loop.

只愿长相守 提交于 2020-01-04 14:19:17
问题 For loop with multiple variables in python 2.7. Hello, I am not certain how to go about this, I have a function that goes to a site and downloads a .csv file. It saves the .csv file in a particular format: name_uniqueID_dataType.csv. here is the code import requests name = "name1" id = "id1" dataType = "type1" def downloadData(): URL = "http://www.website.com/data/%s" %name #downloads the file from the website. The last part of the URL is the name r = requests.get(URL) with open("data/%s_%s_

How to vectorize nested for-loops when column j is used as a row number (e.g. mydata[j, “var”])?

淺唱寂寞╮ 提交于 2020-01-04 14:01:36
问题 I am trying to vectorize my code and need some help. Here is a dummy example. a <- c(0, 0, 0) b <- c(0, 0, 0) c <- c(0, 0, 0) rm <- c(1, 2, 3) var1 <- c(100, 101, 102) var2 <- c(200, 201, 202) var3 <- c(300, 301, 302) mat <- data.matrix(cbind(a, b, c, rm, var1, var2, var3)) num <- 3 for (i in 1:num) { for (j in 1:num) { mat[i, j] <- mat[i, 1+num+ mat[j, "rm"]] } } 来源: https://stackoverflow.com/questions/52594597/how-to-vectorize-nested-for-loops-when-column-j-is-used-as-a-row-number-e-g-my

consistent matched pairs in R

和自甴很熟 提交于 2020-01-04 13:39:31
问题 So using the Matching Package (Link to package here) We can work through a modified GenMatch example. library(Matching) data(lalonde) #introduce an id vaiable lalonde$ID <- 1:length(lalonde$age) X = cbind(lalonde$age, lalonde$educ, lalonde$black, lalonde$hisp, lalonde$married, lalonde$nodegr, lalonde$u74, lalonde$u75, lalonde$re75, lalonde$re74) BalanceMat <- cbind(lalonde$age, lalonde$educ, lalonde$black, lalonde$hisp, lalonde$married, lalonde$nodegr, lalonde$u74, lalonde$u75, lalonde$re75,