I have the following situation:
Customers contain projects and projects contain licenses.
Good because of archiving we won't delete anything but we use the IsDeleted instead.
Otherweise I could have used the cascade deletion.
Owkay I work with the repository pattern so I call
customerRepository.Delete(customer);
But here starts the...
Here is an example array:
$foo = array(
'employer' => array(
'name' => 'Foobar Inc',
'phone' => '555-555-5555'
),
'employee' => array(
'name' => 'John Doe',
'phone' => '555-555-5556',
'address' ...
Is the ability to recursively call a function a capability inherent of the processor or the programming language/compiler. Perhaps, both need elements to support recursion?
I've always been under the impression that the ability to recursively call a function is purely implemented in the programming language and how it lays out its runti...
I had a problem this week (which thankfully I've solved in a much better way);
I needed to keep a couple of fields in a database constant.
So, I knocked up a script to place a Trigger on the table, that would set the value back to a preset number when either an insert, or update took place.
The database is RDB running on VMS (but i'...
Tail recursion is an important performance optimisation stragegy in functional languages because it allows recursive calls to consume constant stack (rather than O(n)).
Are there any problems that simply cannot be written in a tail-recursive style, or is it always possible to convert a naively-recursive function into a tail-recursive on...
This is a quick question, I did a search but couldn't find anything that answered my question.
When doing a recursive function in C do you need to have a return even when using a void function?
Eg:
void addToLL(structA_ptr new, structA_ptr cur) {
if (cur->next == NULL) {
cur->next = new;
} else {
...
I am trying to use the PHP recursive directory iterator to find php and html files in order to list those by date. The code used is as follows:
$filelist = array();
$iterator = new RecursiveDirectoryIterator( $this->_jrootpath );
foreach(new RecursiveIteratorIterator($iterator) as $file) {
if ( !$file->isDir() ) {
if ( preg_...
In a project I have a text with patterns like that:
{| text {| text |} text |}
more text
I want to get the first part with brackets. For this I use preg_match recursively. The following code works fine already:
preg_match('/\{((?>[^\{\}]+)|(?R))*\}/x',$text,$matches);
But if I add the symbol "|", I got an empty result and I don't kn...
Hello,
I need to write a code for this assignment, subject of study is recursive methods:
Example: Consider arr={0,5,1,1,2}. Indices 0,2 and 3 are well-placed:
Index 0 is well-placed since P0=0.
Index 1 is not well-placed, since P1=5>1. Since all elements are positive, it’s impossible to find a sequence starting at index 1 that can ...
I want to know how much disk space is being used by zip files (or any other extension) in a particular directory tree. Is this possible on the command line (in a batch program)?
I can list them, ie: dir /s *.zip
or using "forfiles": forfiles /p d:\wincap /s /m *.zip /c "cmd /c echo @fsize"
I need it in a batch program, because I wan...
Given a problem, how to come up with a recurrence equation?
For example :
Let S be a set of n>0 distinct integers. Assume that n is a power of 3.
A ternary comparison can compare three numbers from the set S and
order them from the largest to the smallest.
Describe an efficient algorithm that uses as few as possible ternary compariso...
So I have what I think is pretty good code for a sudoku solver in java but I need some help with this method. It gives me a stack overflow when I embed it in a main method. The problem is that my method doesn't know how to turn around and fix its mistakes. I need a boolean flag (one that, unlike the one used in the code below, actually w...
Does anyone know if there is some option in VS2010 or some third party tool that I can use to detect recursive properties such as:
private string name;
public string Name
{
get{ return this.Name; }
}
The above is obviously an error, but the compiler offers no warnings. I can appreciate that, in general, recursive methods are perf...
I have a member function of an object that is typically used in an iterative manner but occasionally in a recursive manner. The function is basically following the path of a stream of water downhill, and under certain conditions the stream could split. In order to support the occasional recursion I have to push the state of the object ...
#include <iostream>
using namespace std;
int recursiveMinimum(int [], int n);
int main ()
{
int theArray[3] = {1,2,3};
cout << recursiveMinimum(theArray, 0);
cout << endl;
return 0;
}
// pass in array and 0 to indicate first element
// returns smallest number in an array
int recursiveMinimum (int anArray[], int n) /...
I have a PHP array that looks like this:
Array
(
[340] => Array
(
[1] => 1
[2] => 18
[3] => 23
)
[341] => Array
(
[1] => 1
[2] => 17
[3] => 23
)
[342] => Array
(
[1] => 1
[2] => 16
[3] => 23
)
[343] => Array
)
The array is actually longe...
Hi,
I have this homework assignment:
Let Pi be the element of arr in index i. We say an index i is ‘well-placed’ if there exists an index j (j >= i) so that summing the elements in Pi Pi+1 … Pj yields the index i. In other words, an index is ‘well-placed’ if a sequence of elements beginning at that index yields the index when summed....
public static void main (String[] args)
{
System.out.println(factorial(5));
}
public int factorial(int n)
{
if(n <= 1){
return 1;
}
else{
return n * factorial(n - 1);
}
}
I wrote the above directly in here so may not compile but think it does.
Can anyone breiefly explain how this works in the sence...
Hi all,
I have a PHP array like this (sans syntax):
array
(
['one'] => array (
['wantedkey'] => 5
['otherkey1'] => 6
['otherkey2'] => 7
)
['two'] => => array (
['otherkey1'] => 5
['otherkey2'] => 6...
Hello all!
I just started learning Objective-C and OOP ... so I have very stupid question :)
I wanna understand how to write recursive functions in Objective-C.
I get factorial counting as example. Here is my code )) he-he
#import <Foundation/Foundation.h>
@interface Factorial : NSObject
{
int nFact;
}
-(int) countFactorial:(in...