loops Questions
5
Solved
In Python I can do this:
>>> import itertools
>>> for i, j, in itertools.product(range(3), repeat=2): print i, j
...
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
Is it possible to have ...
2
Solved
Using Loop invariant to prove correctness of merge sort (Initialization , Maintenance , Termination)
How would you go about proving the correctness of merge sort with reasoning over the states of loop invariants?.The only thing that i can visualize is that during the merge step the subarrays(invar...
Pygmy asked 9/11, 2016 at 3:23
4
Solved
I have a windows batch file that does this:
for %%s in (*.sql) do call
It loops through all the sql script in a folder.
In the folder the file names are like:
s4.06.01.sql
s4.07.01.sql
s4.08.01....
Lobworm asked 31/8, 2010 at 6:22
3
I am using @react-keycloak/web for React app securing using keycloak.
I have recently started using KeyCloak with React. My KeyCloak Docker is running on Port 8080 and my React application is runni...
1
Solved
The following is a question about the performance of the ABAP TRY/CATCH construct. In particular, it is not about throwing or catching exceptions.
Is there a performance cost when entering TRY/CATC...
Regazzi asked 13/2, 2023 at 12:17
3
Solved
I am trying to understand the MARIE assembly language. I don't quite understand skipcond for
doing things like <, or >, or multiply or divide.
I am taking this simple program:
x = 1
while x...
Bicentenary asked 27/2, 2011 at 23:35
10
I have a list of words:
words=["alpha","omega","up","down","over","under","purple","red","blue","green"]
I have two functions that are supposed to find the shortest and longest words in this list:...
4
Solved
Is there any "pythonic" way to do this? I am pretty sure my method is not good:
sample = "This is a string"
n = 3 # I want to iterate over every third element
i = 1
for x in sam...
6
Consider something like...
for (int i = 0; i < test.size(); ++i) {
test[i].foo();
test[i].bar();
}
Now consider..
for (int i = 0; i < test.size(); ++i) {
test[i].foo();
}
for (int i = ...
Ambroseambrosi asked 24/10, 2010 at 2:50
5
Solved
I'm trying to write a few lines of code to make a case insensitive array unique type function. Here's what I have so far:
foreach ($topics as $value) {
$lvalue = strtolower($value);
$uvalue = st...
17
Solved
I am trying to iterate over a formArray in my component but I get the following error
Error: Cannot find control with unspecified name attribute
Here is what the logic looks like on my class fil...
Bust asked 16/4, 2017 at 13:21
3
Solved
iterate :: (a -> a) -> a -> [a]
(As you probably know) iterate is a function that takes a function and starting value. Then it applies the function to the starting value, then it applies...
Grille asked 22/9, 2010 at 13:34
1
Solved
I have a Blazor Hosted WebAssembly application under .NET8. That means I have a Client, a Server and a Shared projects.
Into Server, I have the following controller, which has a loop which triggers...
Outsider asked 27/5 at 14:14
22
I need to create a method that receives a String and also returns a String.
Ex input: AAABBBBCC
Ex output: 3A4B2C
Well, this is quite embarrassing and I couldn't manage to do it on the intervie...
Lammas asked 18/5, 2012 at 6:4
4
Solved
I have a server with multiple databases. I need to loop through these databases and change a value in one record, in one table, in each database. How can this be done?
Rentier asked 8/7, 2010 at 17:28
8
Solved
I have an guaranteed to be a perfect square matrix. I want to start at the center of the matrix in this case it would be matrix[2][2], I know how to figure the center (int)(dimensions / 2). I need ...
4
Solved
I have a dataframe and 2 lists.
the 1st list gives a set of index values from the dataframe I want to replace
the 2nd list gives the values I want to use
I don't want to touch any of the other v...
5
Solved
2
Solved
I am asking this question only for the sake of knowledge(because i think it has nothing to do with beginner like me).
I read that C-programmers prefer
for(; ;) {....}
over
while(1) {....}
...
Serbocroatian asked 30/6, 2013 at 20:44
3
Solved
I am trying to loop through a Polars recordset using the following code:
import polars as pl
df = pl.DataFrame({
"start_date": ["2020-01-02", "2020-01-03", "202...
Staggs asked 2/2, 2023 at 13:15
3
Solved
Infinite loops without side effect are undefined behaviour. See here for the example from cppreference. Much simpler example:
int foo() {
while(true) {}
return 42;
}
Now consider the almost eq...
Judie asked 17/4, 2019 at 19:23
5
Given a numpy array of the form below:
x = [[4.,3.,2.,1.,8.],[1.2,3.1,0.,9.2,5.5],[0.2,7.0,4.4,0.2,1.3]]
is there a way to retain the top-3 values in each row and set others to zero in python (w...
Albacore asked 19/12, 2019 at 2:29
11
Solved
When I should use a while loop or a for loop in Python? It looks like people prefer using a for loop (for brevity?). Is there any specific situation which I should use one or the other? Is it a mat...
6
Solved
I am not sure what the problem is but I keep receiving this error when I try to use a while statement in my code.
Invalid token 'while' in class,
struct, or interface member
declaration
I wa...
Camara asked 29/12, 2008 at 2:38
15
Solved
Go's range can iterate over maps and slices, but I was wondering if there is a way to iterate over a range of numbers, something like this:
for i := range [1..10] {
fmt.Println(i)
}
Or is there...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.