loops

The Haskell way to do IO Loops (without explicit recursion)?

眉间皱痕 提交于 2020-01-24 06:45:07
问题 I want to read a list of strings seperated by newlines from STDIN, until a new line is witnessed and I want an action of the type IO [String] . Here is how I would do it with recursion: myReadList :: IO String myReadList = go [] where go :: [String] -> IO [String] go l = do { inp <- getLine; if (inp == "") then return l; else go (inp:l); } However, this method of using go obscures readability and is a pattern so common that one would ideally want to abstract this out. So, this was my attempt:

SQL iterating over a list to call EXEC on each item

狂风中的少年 提交于 2020-01-24 05:38:28
问题 Attempt to generalize my questions... I want to execute a stored procedure for each result returned by a SELECT statement. Mentally I want to try something like EXEC myStoredProc (SELECT id FROM sometable WHERE cond = @param) More details related to my specific case... I have a SaaS application. I would like to delete a tenant from the system. Before I can delete the tenant I must delete all records in the database associated with that tenant. Tenants own items such as Forms which contain

Loop through all worksheets in all Excel workbooks in a folder to change the font, font size, and alignment of text in all cells

我只是一个虾纸丫 提交于 2020-01-24 01:26:13
问题 On my hard drive I have a folder containing a number of Excel workbooks. I want to loop though all the worksheets in each of the Excel workbooks in this folder to change the font, font size, and alignment of text in all the cells. From my own limited knowledge of VBA and from reading other related questions here on SO I have cobbled toghether the macro below which I have stored in Personal.xls. As it is now it seems to loop through the workbooks but it is not formating the text in any of them

A Callback to $.each()'s Callback? [closed]

穿精又带淫゛_ 提交于 2020-01-24 00:43:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 years ago . Update: The code below does indeed work as expected, and accomplishes the code I wanted. My confusion was in understanding what I had in my markup when writing the code below - after giving my markup a second look, I realized my code worked perfectly. I've provided my answer below for all who are interested in

Cannot enter in while statement [duplicate]

江枫思渺然 提交于 2020-01-24 00:18:13
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Unsigned and signed comparison unsigned int and signed char comparison I have a strange behavior when i try to enter in this while statement: unsigned u = 0; int i = -2; while(i < u) { // Do something i++; } But it never enters, even if when i set a break point i = -2 and u = 0 . What am I doing wrong? How could i fix this? 回答1: It's because the ANSI C standard defines that whenever there is a comparison between

How can i use jar file into loop counter - Jmeter

若如初见. 提交于 2020-01-23 18:02:35
问题 I want to create scenario where i want use data from jar file into Jmeter Loop logic. My jar looks like: public String Australia() { String a = "{" + "\"location\": {" + "\"lat\": -33.8669710," + "\"lng\": 151.1958750" + "}," + "\"accuracy\": 50," + "\"name\": \"Google Shoes!\"," + "\"phone_number\": \"(02) 9374 4000\"," + "\"address\": \"48 Pirrama Road, Pyrmont, NSW 2009, Australia\"," + "\"types\": [\"shoe_store\"]," + "\"website\": \"http://www.google.com.au/\"," + "\"language\": \"en-AU\

Matplotlib: subplot

只愿长相守 提交于 2020-01-23 17:04:12
问题 I have several time series signals (8x8) that I would like to plot using subplot. My data are stored in a matrix called H(x, y, N) where N is the number of points in each signal. I would like to display the 64 signals using subplots. fig = figure(figsize=(12,8)) time = np.arange(0, Nt, 1) for x in range(8): for y in range(8): subplot(8,y+1,x+1) plot(time,H[x,y,:]) What I get is 8 signals in the first row, 4 in the second one, then 2, 2, 1, 1, 1 and 1. 回答1: That's not how subplot indexing

Matplotlib: subplot

馋奶兔 提交于 2020-01-23 17:03:59
问题 I have several time series signals (8x8) that I would like to plot using subplot. My data are stored in a matrix called H(x, y, N) where N is the number of points in each signal. I would like to display the 64 signals using subplots. fig = figure(figsize=(12,8)) time = np.arange(0, Nt, 1) for x in range(8): for y in range(8): subplot(8,y+1,x+1) plot(time,H[x,y,:]) What I get is 8 signals in the first row, 4 in the second one, then 2, 2, 1, 1, 1 and 1. 回答1: That's not how subplot indexing

Matplotlib: subplot

冷暖自知 提交于 2020-01-23 17:03:05
问题 I have several time series signals (8x8) that I would like to plot using subplot. My data are stored in a matrix called H(x, y, N) where N is the number of points in each signal. I would like to display the 64 signals using subplots. fig = figure(figsize=(12,8)) time = np.arange(0, Nt, 1) for x in range(8): for y in range(8): subplot(8,y+1,x+1) plot(time,H[x,y,:]) What I get is 8 signals in the first row, 4 in the second one, then 2, 2, 1, 1, 1 and 1. 回答1: That's not how subplot indexing

Matplotlib: subplot

て烟熏妆下的殇ゞ 提交于 2020-01-23 17:03:04
问题 I have several time series signals (8x8) that I would like to plot using subplot. My data are stored in a matrix called H(x, y, N) where N is the number of points in each signal. I would like to display the 64 signals using subplots. fig = figure(figsize=(12,8)) time = np.arange(0, Nt, 1) for x in range(8): for y in range(8): subplot(8,y+1,x+1) plot(time,H[x,y,:]) What I get is 8 signals in the first row, 4 in the second one, then 2, 2, 1, 1, 1 and 1. 回答1: That's not how subplot indexing