All Questions
Tagged with program-flow or control-flow
922 questions
-4
votes
3
answers
142
views
How does control flow work in nested loops in C? (Understanding execution order) [closed]
While practising nested loops in C, I wanted to understand how control flows between an outer loop and an inner loop. I understood that the inner loop runs for each iteration of the outer loop, but ...
4
votes
1
answer
51
views
In Racket, why does parameterize not work lexically with shift/reset?
Consider the following piece of code:
(define p (make-parameter 'outer))
(reset
(parameterize ([p 'inner])
(displayln (p)) ; prints 'inner
(shift k
(begin
(displayln (p)) ; ...
0
votes
0
answers
55
views
How to use tf.withControlDependencies in tensorflow Java API?
I want to put two tensors into a map, and then get one tensor from the map. To ensure tf.tensorMapInsert is executed, I use tf.withControlDependencies - but it does not work.
Here is my code:
Operand&...
0
votes
1
answer
39
views
Validation inside of the method or outside
Let's say I have a list of users in my app, and I have to send a notification only to those who meet certain criteria, for example, a user should be in a specific country.
I have 2 classes, ...
0
votes
3
answers
194
views
Is every line of code executed only once (when loops aren't used)? [closed]
Is every line of code executed only once (when loops aren't used)?
#include <stdio.h>
int main() {
int a = 1; // Variable 'a' is initialized to 1
printf("%d\n", a); // ...
-3
votes
1
answer
266
views
How to draw the control flow graph for the following C program?
I am learning about control flow graphs and came across this example.
int binsearch(int x, int v[], int n) {
int low, high, mid; // Line 1
low = 0; ...
2
votes
1
answer
95
views
Why does the assembly code stop functioning right when I remove an unused variable?
I'm a beginner in assembly and I'm encountering unexpected behavior in my code. The code works as expected, printing numbers from contador variable to 1, but when I removed the unused variable loops (...
-1
votes
1
answer
160
views
Conditions in functions in pandas
I am new to Pandas and trying to figure out how to create/use functions, perform simple if-else statements. I wrote the following function average_shares(), but it doesn't work as I expect (because it ...
3
votes
2
answers
1k
views
Control flow migration Error on Angular 18: @switch can only have @case or @default as childre
I tried to migrate to control flow format in my Angular 18 projects in nx workspace. For most of the templates worked perfectly but for one html I'm getting the following error:
[ngSwitch]: Error: ...
0
votes
0
answers
31
views
Can you import libraries in if statements in Python? [duplicate]
I'm working on some code that grabs some data from a website and then transforms it into a data object that will work for whatever machine learning library the user is using. I wanted to do some ...
-1
votes
1
answer
47
views
Is there a tool or specific syntax to insert cases into switches with consecutive indices and make the indices below adjust
I have a function that takes an integer and returns a string that is picked by a switch. The strings are part of a coherent text and I want to be able to add cases to the switch whenever I want to ...
-2
votes
1
answer
42
views
Can you execute a block of code if a python loop is not broken [duplicate]
I'm looking for a more pythonic way to construct this check:
good_result = None
for item in items:
result = process(item)
if result.isGood():
good_result = result
break
if not ...
2
votes
2
answers
5k
views
Angular new control flow @for with async pipe and aliasing variable with as
I migrated from the structural directives *ngIf and *ngFor to the new control flow with @if and @for in Angular.
But there is one case that I used previously but I cannot seem to get it to work with ...
0
votes
0
answers
320
views
Angular 17 template code completion not working in PhpStorm 2024.1.1
I migrated project to Angular 17.3.6. Also updated PhpStorm to 2024.1.1 and there is recent Angular plugin. I cannot get IDE to provide code completion in Angular templates. Also it doesn't recognize ...
0
votes
4
answers
249
views
Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
From my previous knowledge the (logical AND) has a higher precedence than the (logical OR), so for example in the following line of Java code boolExp2 will be compared with boolExp3 before comparing ...
0
votes
0
answers
56
views
Get control flow information with JaCoCo
Looking for a way to retrieve control flow information, such as local variables and their values and which instructions/branches were executed for the tested methods using JaCoCo (0.8.11). I am ...
2
votes
1
answer
114
views
Why does a continue in this ForEach-Object loop cause Powershell to error
When piping the output of a command to a ForEach-Object loop in PowerShell, using a continue statement causes it to error out.
Works as expected:
ipconfig | ForEach-Object {
$_
}
Errors:
ipconfig |...
0
votes
1
answer
64
views
How to copy function instructions and store them in buffer? [closed]
Why isn't this code directly storing the assembly instructions of func into the buffer? The value of the buffer is junk and doesn't change.
#include <stdio.h>
#include <stdlib.h>
#...
0
votes
1
answer
3k
views
how do i make a floating window that stays above programs, moveable and will accept input from another script
I am trying to build an indesign script that will produce a floating window that can display report results. I need to use this as a check-off "sheet" that will stay visible and moveable. ...
1
vote
1
answer
995
views
Angular: How to reference the result of a function in the new control flow @if with an logical AND (&&)
With the old control flow I could reference the result of a function in this way.
<span *ngIf="column.getValue && column.getValue(item) as value">{{value}}</span>
But ...
1
vote
1
answer
184
views
Missing return statement in for loop with condition
I have noticed that when I write the following code, the compiler yields a missing return statement error:
// Similar loops make sense in retry patterns
// but this is just a simple example
func ...
1
vote
1
answer
249
views
How to get reasonable "topological order" of control flow graph (CFG) which may have loops when calculating MD index?
I am a noob in binary analysis and I am looking for your help.
I am working on calculating the MD index of callgraph function nodes by Python, and I have to analyze the control flow graph (CFG) inside ...
1
vote
1
answer
784
views
Not able to use temp tables in one "Execute SQL Task" after another in SSIS Control Flow
I have two tasks in control flow. The first task is in sequence container and creates multiple global temp tables. The second task uses these temp tables. Both the tasks are in 'Execute SQL Task'. ...
0
votes
0
answers
61
views
How can a foor loop with an array index be 3x slower then a switch case into a function that does the same thing?
I was benchmarking function pointers vs switch case statements in quick-bench and got the expected result. Function pointers are slower than switch case. But I wanted to remove the operation from the ...
0
votes
0
answers
42
views
How do you populate spreadsheet data in the same row when the instance to some of the variables occur at different times in C++
I need to dump data to a spreadsheet relevant to an alert condition being true but an aspect of the data will occur at a latter time then the alert condition being true. So if my alert is true at 2023-...
0
votes
0
answers
73
views
Problem with the flow of program execution resulting unexpected behaviour
I have written an Assembly x64 Assembly code (NASM compatible) that is getting compiled and running on Linux but outputs an unexpected portion of the code.
What this code does is that it takes a ...
-1
votes
2
answers
97
views
Nested if else statement is not working as desired
In the program, no errors.
PASS, CLEARED user inputs are working as desired.
But when I enter NO as user input in the nested if, control picks "else statement" correctly, but also it is ...
0
votes
1
answer
97
views
Clang Analysis CFG loop identification finds the while loop but fails to print the associated code fragment and line number
I am trying to use Clang to find all the loops at the source code level of an input source file. My code currently can identify for-loops in the source file and printout the line number. It also seems ...
1
vote
3
answers
146
views
How to always apply a method before executing another method via a proxy?
I have the following code where I want to invoke the instance method connect before proceeding with the invocation of every other instance method of the TelegramClient class. How can this be achieved ...
0
votes
1
answer
270
views
Xamarin/MAUI USB ControlTransfor
i am trying to create a maui app for android that can talk to and control a specific hid device. i already have the usb device found, and as far as i know i have a connection to the device. But trying ...
0
votes
1
answer
73
views
How can I avoid having lots of if statements when finding combinations of radio buttons?
I have a database that looks like this:
Rat
Age
RA
RB
RAB
RC
RD
RCD
A
1
None
None
Mild
Severe
None
Death
B
2
Mild
Severe
Severe
None
Mild
Severe
RA stands for reaction to substance A, RB reaction to ...
0
votes
1
answer
47
views
Pythonic way to replace > with < in the midst of a big for loop
I'm trying to write a big for-loop that executes some nested logic. I'd like to control which comparisons get applied with a kwarg in my function. Basically, I have two different comparisons, both ...
0
votes
1
answer
61
views
Execution of 'You lost' loop in Hangman game despite winning the game on the last try
I have been trying to build a Hangman game, but I am facing a problem. The game runs fine, but every time I guess the word on my last chance, instead of the “You won!” block being executed, the “You ...
0
votes
0
answers
70
views
How to reduce array of unique-discriminator union objects into object with key of discriminator type and value of related union item
I have an array of discriminated union objects
type Discriminated = {
discriminator: 'a'
a: string;
} | {
discriminator: 'b',
b: number;
}
const arr: Discriminated[] = [
{
discriminator:...
2
votes
1
answer
353
views
Semantic information in AST
Suppose we have classic Abstract Syntax Tree of a program. I wonder worth it to put purely semantic information (referred variable type, size in bytes, etc) in AST? I need all this stuff for different ...
0
votes
1
answer
218
views
SSIS Script Task has green arrow but now red arrow by default. how to get the red arrow for error handling?
I see I am allowed to do statements like this within my script task:
Dts.TaskResult = (int)ScriptResults.Success;
Dts.TaskResult = (int)ScriptResults.Failure;
New to SSIS, and I could not find this ...
1
vote
0
answers
223
views
How does Next.js routing work from browser to application under the hood?
I am trying to understand the Next.js routing fundamentally so that I can customize it according to my need. But I wasn't able to find about the workflow of the routing with a high-level explanation. ...
0
votes
1
answer
85
views
Confusion about generating intermediate code for control-of-flow statements in the dragon book
Section 6.6.3 of the dragon book (Compilers: Principles, Techniques, and Tools 2nd Edition) describes how to translate the flow-of-control statements like if/if-else/while into intermediate code.
For ...
0
votes
1
answer
179
views
Best option for control flow in VBA? [closed]
I'm updating a macro and need help with the control flow. I'm not a programmer by trade, so control flow isn't something I've encountered before.
The current version of the macro works as follows:
...
-2
votes
1
answer
160
views
indentation to make software control flow apparent. What do you think about it? [closed]
How many times have you encountered a function with a return statement deep within the code? Or failed to notice a break or a continue in a loop? While I have not been blindsided by return recently, I ...
1
vote
1
answer
2k
views
How to re-write this control-flow Python function to be JAX-compatible?
I'm rewriting some code from Pure Python to JAX. I have a function that has if/else statements in it that depend on the value of the input variable. I know these kinds of "control flow" ...
0
votes
2
answers
155
views
Handling Typescript type checking in constructor
With the following (very contrived) example where:
If the object has a certain value for an attribute, then another (optional) attribute must be defined. I want to catch errors in the constructor so ...
0
votes
2
answers
171
views
Class cast exception in clojure
Getting clojure.core$count cannot be cast to java.lang.Number error for defined variable count
(defroutes jobs-routes
(context "/jobs" []
(POST "/jobValidation" [name ...
-1
votes
1
answer
105
views
Java Comparison of If/While Loop
Working on a leetcode problem described as: "Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's."
I am using ...
0
votes
1
answer
47
views
print function doesn't execute outside a while cycle
i have this function that works as intended except for the fact that the last print instruction outside the while cycle (print("why don't you print?")) never get executed and i don't ...
0
votes
0
answers
48
views
R conditional loop, multiple lists
I need help stepping through a second loop in R when a test fails in my first loop. Here's the logic:
to start use config_list[1] from list
then download file path_list[1] from list
check if file ...
-4
votes
2
answers
49
views
difference between controlling the flow with if and elif
i was running a program that return the maximum 2 number in a certain list
and I found that there a difference between using if and elif in definition of function
So if i used :
def maxi (lst) :
...
1
vote
1
answer
393
views
Is there a design pattern in JavaScript for writing functions that can conditionally throw an exception or capture it to return a value?
Sometimes there is a need to call a function and handle the exception directly (with a try/catch), and other times there it is preferable to call the same function and receive a null or false if it ...
0
votes
2
answers
3k
views
Looping back to the beginning of a while loop
I am building a simple rock paper scissors game. Everytime you win, you gain a point. Same for the computer. Between the player and computer, the first to get 3 points wins. Everything worked fine but ...
0
votes
1
answer
54
views
Ifelse fails in render function
The following code works. The functional line of code is p1+p2+p3+p4+show. However, if I comment that line out and uncomment the commented lines, the app still works, but the associated map doesn't ...