control-structure Questions

4

Solved

Today I was looking through the php manual and stumbled upon a control structure declare. The declare construct is used to set execution directives for a block of code This is what declare i...
Eclogue asked 8/7, 2015 at 5:19

2

Solved

As noted in another StackOverflow answer that I can't seem to find anymore, this pattern emerges frequently in practical Prolog code: pred(X) :- guard(X), ... pred(X) :- \+ guard(X), ... and...

6

Solved

1st off I'm new to PHP. I have been using for loop,while loop,foreach loop in scripts. I wonder which one is better for performance? what's the criteria to select a loop? which should be used wh...
Eudemon asked 11/10, 2012 at 19:58

2

In a SQL Server 2012 stored procedure, I have several nested structures. I want to break out of a single layer of them. I thought the description of BREAK in the msdn https://msdn.microsoft.com/e...
Laflamme asked 15/12, 2015 at 19:9

1

Solved

A simple PHP if / else condition looks like this: if(true) { echo("Hello World!"); } else { echo("Goodbye World!"); } The "alternative syntax" looks like this: if(true): echo("Hello World!")...
Hedden asked 14/6, 2016 at 18:2

6

Solved

I have a question regarding if not statement in Python 2.7. I have written some code and used if not statements. In one part of the code I wrote, I refer to a function which includes an if not st...
Contaminant asked 23/2, 2016 at 8:44

5

Solved

I am currently working on somebody's else code, with a statement like this if(x.start()) do if(y.foo(x)) { // Do things }while(x.inc()) here x is custom class that holds information on y and a...
Emylee asked 29/7, 2015 at 10:32

1

Solved

Is it possible to use something like this in Postgres? This is the example from PL/SQL what I want to do: PROCEDURE CREATE_PAYMENT(P_AMOUNT IN NUMBER, P_INVOICE_LIST IN SIMPLEARRAYTYPE, P_AMOUN...
Hernia asked 30/12, 2014 at 15:35

8

Solved

I've seen this a lot: $fp = fopen($filepath, "w") or die(); But I can't seem to find any real documentation on this "or" syntax. It's obvious enough what it does, but can I use it anywhere? And mus...
Discus asked 2/3, 2012 at 14:51

1

Solved

is it possible to create single if (without else) ? It is very usable to can use one if
Enjoyment asked 12/10, 2013 at 20:9

10

Solved

I have a range of whole numbers that might or might not have some numbers missing. Is it possible to find the smallest missing number without using a loop structure? If there are no missing numbers...
Polynesia asked 15/8, 2013 at 21:55

3

I've been thinking to much... In the area of switch case is break; required after die() Example: switch($i){ case 0: die('Case without break;'); case 1: die('Case with break;'); break; }...
Muncey asked 9/8, 2013 at 19:1

2

Solved

catch in Ruby is meant to jump out of deeply nested code. In Java e.g. it is possible to achieve the same with Java's try-catch meant for handling exceptions, it is however considered poor solution...
Bentinck asked 20/11, 2012 at 23:29

6

Solved

I need to make a decision based on a rather large set of 8 co-dependent conditions. | A | B | C | D | E | F | G | H -----------+---+---+---+---+---+---+---+--- Decision01 | 0 | 1 | - | 1 | 0 | 1...
Fixing asked 3/6, 2013 at 15:58

13

Solved

When reviewing, I sometimes encounter this kind of loop: i = begin while ( i != end ) { // ... do stuff if ( i == end-1 (the one-but-last element) ) { ... do other stuff } increment i } Th...

3

Solved

I am porting a Java application to Haskell. The main method of the Java application follows the pattern: public static void main(String [] args) { if (args.length == 0) { System.out.println("In...
Neology asked 20/12, 2012 at 10:55

1

Solved

I always used and seen examples with just "break". What is the meaning of this: <?php while ($flavor = "chocolate") { switch ($flavor) { case "strawberry"; echo "Strawberry is stock!";...
Encomium asked 23/9, 2012 at 13:26

28

Sometimes when I am programming, I find that some particular control structure would be very useful to me, but is not directly available in my programming language. I think my most common desire is...
Misconstrue asked 27/11, 2010 at 20:27

5

Solved

I need to write these four ifs in Python. Notice what it does, is changing between four possible states in a loop: 1,0 -> 0,1 -> -1,0 -> 0,-1 and back to first. if [dx, dy] == [1,0]: dx,...
Hackler asked 1/2, 2012 at 23:8

3

Solved

Is it possible to break from a switch and then continue in a loop? For example: $numbers= array(1,2,3,4,5,6,7,8,9,0); $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g'); foreach($letters as $le...
Predicate asked 20/11, 2011 at 22:55

4

Solved

Structured programming languages typically have a few control structures, like while, if, for, do, switch, break, and continue that are used to express high-level structures in source code. Howeve...

4

Solved

Is it possible to create a custom control structure with several code blocks, in the fashion of before { block1 } then { block2 } finally { block3 }? The question is about the sugar part only - I k...
Virgel asked 1/1, 2011 at 8:43

2

Solved

I'm really bothered by having to nest using blocks in C#. It's not elegant and it takes up a lot of space. In some cases it appears to be unavoidable because I need to declare variables of differen...
Jodhpur asked 10/8, 2010 at 13:43

5

Solved

I've been working on PHP for some time but today when I saw this it came as new to me: if(preg_match('/foo.*bar/','foo is a bar')): echo 'success '; echo 'foo comes before bar'; endif; To my ...
Serpens asked 7/5, 2010 at 13:31

18

Like Smalltalk or Lisp? EDIT Where control structures are like: Java Python if( condition ) { if cond: doSomething doSomething } Or Java Python while( true ) { while True: print(...

© 2022 - 2024 — McMap. All rights reserved.