Search Results

Search found 1112 results on 45 pages for 'recursive'.

Page 13/45 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Why does Gnumake from parent directory behave differently?

    - by WilliamKF
    I am stumped as to why when I do a gnumake from the parent directory it behaves incorrectly, whereas, if I cd to the subdirectory and do gnumake it works correctly. In the parent makefile, I have a rule like this: .PHONY: zlib-1.2.5 zlib-1.2.5: @ echo Issuing $(MAKE) in $@ ... pushd zlib-1.2.5; make; popd Which gives different result than doing the same from the toplevel pushd zlib-1.2.5; make; popd There is a something from the parent makefile that is making its way into the subdirectory makefile and causing it to behave incorrectly, but I don't know how to find it. The symptom I see is that the subdirectory config generated makefile rule for zlib misses the dependencies and I get this result going straight to the ar without generating the .o(s) first: cd ~/src; make zlib-1.2.5 CPPFLAGS_AUTO = < > Issuing make in zlib-1.2.5 ... pushd zlib-1.2.5; make; popd ~/src/zlib-1.2.5 ~/src make[1]: Entering directory `/disk2/user/src/zlib-1.2.5' ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o ar: adler32.o: No such file or directory make[1]: *** [libz.a] Error 1 gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a gcc: adler32.lo: No such file or directory gcc: compress.lo: No such file or directory gcc: crc32.lo: No such file or directory gcc: deflate.lo: No such file or directory [...] make[1]: *** [libz.so.1.2.5] Error 1 make[1]: Target `all' not remade because of errors. make[1]: Leaving directory `/disk2/user/src/zlib-1.2.5' ~/src Versus from the zlib directory where it works correctly: cd ~/src/zlib-1.2.5; make gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o example.o example.c gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o adler32.o adler32.c gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o compress.o compress.c gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o crc32.o crc32.c [...] gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o zutil.o zutil.c ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o (ranlib libz.a || true) >/dev/null 2>&1 gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example example.o -L. libz.a gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o minigzip.o minigzip.c gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip minigzip.o -L. libz.a mkdir objs 2>/dev/null || test -d objs gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/adler32.o adler32.c mv objs/adler32.o adler32.lo mkdir objs 2>/dev/null || test -d objs gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/compress.o compress.c mv objs/compress.o compress.lo [...] mkdir objs 2>/dev/null || test -d objs gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/zutil.o zutil.c mv objs/zutil.o zutil.lo gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a rm -f libz.so libz.so.1 ln -s libz.so.1.2.5 libz.so ln -s libz.so.1.2.5 libz.so.1 rmdir objs gcc -O3 -D_LARGEFILE64_SOURCE=1 -o examplesh example.o -L. libz.so.1.2.5 gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzipsh minigzip.o -L. libz.so.1.2.5 gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example64 example64.o -L. libz.a gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip64 minigzip64.o -L. libz.a

    Read the article

  • Aggregate survey results recursively by manager

    - by Ian Roke
    I have a StaffLookup table which looks like this. UserSrn | UserName | ManagerSrn =============================== ABC1 | Jerome | NULL ABC2 | Joe | ABC1 ABC3 | Paul | ABC2 ABC4 | Jack | ABC3 ABC5 | Daniel | ABC3 ABC6 | David | ABC2 ABC7 | Ian | ABC6 ABC8 | Helen | ABC6 The staff structure looks like this. |- Jerome | |- Joe || ||- Paul ||| |||- Jack ||| |||- Daniel || ||- David ||| |||- Ian ||| |||- Helen I have a list of SurveyResponses that looks like this. UserSrn | QuestionId | ResponseScore ==================================== ABC2 | 1 | 5 ABC2 | 3 | 4 ABC4 | 16 | 3 ... What I am trying to do sounds pretty simple but I am struggling to find a neat, quick way of doing it. I want to create a sproc that takes an Srn and returns back all the staff under that Srn in the structure. If there is a score for QuestionId of 16 then that indicates a completed survey. I would like to return a line for the Srn entered (The top manager) with a count of completed surveys for the direct reports under that manager. Under that I would like each manager under the original manager with a count of completed surveys for each of their direct reports and so on. I would like to see the data as such below when I set the top manager to be Joe (ABC2). UserName | Completed | Total ============================ Joe | 2 | 2 Paul | 1 | 2 David | 0 | 2 TOTAL | 3 | 6

    Read the article

  • How to recursively delete some xml elements using XSLT

    - by Monomachus
    Hi, So I got this situation which sucks. I have an XML like this <table border="1" cols="200 100pt 200"> <tr> <td>isbn</td> <td>title</td> <td>price</td> </tr> <tr> <td /> <td /> <td> <span type="champsimple" id="9b297fb5-d12b-46b1-8899-487a2df0104e" categorieid="a1c70692-0427-425b-983c-1a08b6585364" champcoderef="01f12b93-b4c5-401b-9da1-c9385d77e43f"> [prénom] </span> <span type="champsimple" id="e103a6a5-d1be-4c34-8a54-d234179fb4ea" categorieid="a1c70692-0427-425b-983c-1a08b6585364" champcoderef="01f12b93-b4c5-401b-9da1-c9385d77e43f">[nom]</span> <span></span> </td> </tr> <tr></tr> <tr> <td></td> <td>Phill It in</td> </tr> <tr> <table id="cas1"> <tr> <td ></td> <td >foo</td> </tr> <tr> <td >bar</td> <td >boo</td> </tr> </table> </tr> <tr> <table id="cas2"> <tr> <td ></td> <td >foo</td> </tr> <tr> <td ></td> <td >boo</td> </tr> </table> </tr> <tr> <table id="cas3"> <tr> <td >bar</td> <td ></td> </tr> <tr> <td >foo</td> <td >boo</td> </tr> </table> </tr> <tr> <table id="cas4"> <tr> <td /> <td /> </tr> <tr> <td>foo</td> <td>boo</td> </tr> </table> </tr> <table id="cas4"> <tr> <td /> <td /> </tr> <tr> <td>foo</td> <td>boo</td> </tr> </table> <tr> <td /> <td /> </tr> </table> Now the question is how would I recursively delete all empty td, tr and table elements? Now I use this XSLT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*" /> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="td[not(node())]" /> <xsl:template match="tr[not(node())]" /> <xsl:template match="table[not(node())]" /> </xsl:stylesheet> But it doesn't do very well. After I delete td, a tr becomes empty but it doesn't handle that. Too bad. See the table element with "cas4". <table border="1" cols="200 100pt 200"> <tr> <td>isbn</td> <td>title</td> <td>price</td> </tr> <tr> <td> <span type="champsimple" id="9b297fb5-d12b-46b1-8899-487a2df0104e" categorieid="a1c70692-0427-425b-983c-1a08b6585364" champcoderef="01f12b93-b4c5-401b-9da1-c9385d77e43f"> [prénom] </span> <span type="champsimple" id="e103a6a5-d1be-4c34-8a54-d234179fb4ea" categorieid="a1c70692-0427-425b-983c-1a08b6585364" champcoderef="01f12b93-b4c5-401b-9da1-c9385d77e43f">[nom]</span> <span /> </td> </tr> <tr> <td>Phill It in</td> </tr> <tr> <table id="cas1"> <tr> <td>foo</td> </tr> <tr> <td>bar</td> <td>boo</td> </tr> </table> </tr> <tr> <table id="cas2"> <tr> <td>foo</td> </tr> <tr> <td>boo</td> </tr> </table> </tr> <tr> <table id="cas3"> <tr> <td>bar</td> </tr> <tr> <td>foo</td> <td>boo</td> </tr> </table> </tr> <tr> <table id="cas4"> <tr /> <tr> <td>foo</td> <td>boo</td> </tr> </table> </tr> <table id="cas4"> <tr /> <tr> <td>foo</td> <td>boo</td> </tr> </table> <tr /> </table> How would you solve this problem?

    Read the article

  • python: using __import__ to import a module which in turn generates an ImportError

    - by bbb
    Hi there, I have a funny problem I'd like to ask you guys ('n gals) about. I'm importing some module A that is importing some non-existent module B. Of course this will result in an ImportError. This is what A.py looks like import B Now let's import A >>> import A Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/tmp/importtest/A.py", line 1, in <module> import B ImportError: No module named B Alright, on to the problem. How can I know if this ImportError results from importing A or from some corrupt import inside A without looking at the error's string representation. The difference is that either A is not there or does have incorrect import statements. Hope you can help me out... Cheers bb

    Read the article

  • Basic Recursion, Check Balanced Parenthesis

    - by pws5068
    Greetings all, I've written software in the past that uses a stack to check for balanced equations, but now I'm asked to write a similar algorithm recursively to check for properly nested brackets and parenthesis. Good examples: () [] () ([]()[]) Bad examples: ( (] ([)] Suppose my function is called: isBalanced. Should each pass evaluate a smaller substring (until reaching a base case of 2 left)? Or, should I always evaluate the full string and move indices inward?

    Read the article

  • Help me understand Inorder Traversal without using recursion

    - by vito
    I am able to understand preorder traversal without using recursion, but I'm having a hard time with inorder traversal. I just don't seem to get it, perhaps, because I haven't understood the inner working of recursion. This is what I've tried so far: def traverseInorder(node): lifo = Lifo() lifo.push(node) while True: if node is None: break if node.left is not None: lifo.push(node.left) node = node.left continue prev = node while True: if node is None: break print node.value prev = node node = lifo.pop() node = prev if node.right is not None: lifo.push(node.right) node = node.right else: break The inner while-loop just doesn't feel right. Also, some of the elements are getting printed twice; may be I can solve this by checking if that node has been printed before, but that requires another variable, which, again, doesn't feel right. Where am I going wrong? I haven't tried postorder traversal, but I guess it's similar and I will face the same conceptual blockage there, too. Thanks for your time! P.S.: Definitions of Lifo and Node: class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class Lifo: def __init__(self): self.lifo = () def push(self, data): self.lifo = (data, self.lifo) def pop(self): if len(self.lifo) == 0: return None ret, self.lifo = self.lifo return ret

    Read the article

  • boost::Spirit Grammar for unsorted schema

    - by Hassan Syed
    I have a section of a schema for a model that I need to parse. Lets say it looks like the following. { type = "Standard"; hostname="x.y.z"; port="123"; } The properties are: The elements may appear unordered. All elements that are part of the schema must appear, and no other. All of the elements' synthesised attributes go into a struct. (optional) The schema might in the future depend on the type field -- i.e., different fields based on type -- however I am not concerned about this at the moment.

    Read the article

  • Ignore errors when scanning for files in C:\

    - by Shane
    I am trying to search the C:\ drive for all files with a certain extension. I am using the following code which is working fine, however when it encounters an error the whole process stops rather than continuing with the scan. (running in backgroundworker, hence the invoke) Private Sub ScanFiles(ByVal rootFolder As String, ByVal fileExtension As String) 'Determine if the current folder contains any sub folders Dim subFolders() As String = System.IO.Directory.GetDirectories(rootFolder) For Each subFolder As String In subFolders ScanFiles(subFolder, fileExtension) Next For Each file As String In System.IO.Directory.GetFiles(rootFolder, fileExtension) lb.BeginInvoke(New AddValue(AddressOf AddItems), file) Next End Sub How can I make this code continue once an error is encountered? Thanks for your help.

    Read the article

  • Parse Directory Structure (Strings) to JSON using PHP

    - by Ecropolis
    I have an array of file-path strings like this videos/funny/jelloman.wmv videos/funny/bellydance.flv videos/abc.mp4 videos/june.mp4 videos/cleaver.mp4 fun.wmv jimmy.wmv herman.wmv Is there a library or easy way I can get to a data structure json or xml? Something like this: (I see there are a lot of snippets available for traversing actual folders, but again, I just have strings.) { files:{ file:[ { filename:'fun.wmv' }, { filename:'jimmy.wmv' }, { filename:'herman.wmv' } ], folder:{ foldername:'videos', file:[ { filename:'abc.mp4' }, { filename:'june.mp4' }, { filename:'cleaver.mp4' } ], folder:{ foldername:'funny', file:[ { filename:'jelloman.wmv' }, { filename:'bellydance.flv' } ] } } } }

    Read the article

  • In terminal, merging multiple folders into one.

    - by Josh Pinter
    I have a backup directory created by WDBackup (western digital external HD backup util) that contains a directory for each day that it backed up and the incremental contents of just what was backed up. So the hierarchy looks like this: 20100101 My Documents Letter1.doc My Music Best Songs Every First Songs.mp3 My song.mp3 # modified 20100101 20100102 My Documents Important Docs Taxes.doc My Music My Song.mp3 # modified 20100102 ...etc... Only what has changed is backed up and the first backup that was ever made contains all the files selected for backup. What I'm trying to do now is incrementally copy, while keeping the folder structure, from oldest to newest, each of these dated folders into a 'merged' folder so that it overrides the older content and keeps the new stuff. As an example, if just using these two example folders, the final merged folder would look like this: Merged My Documents Important Docs Taxes.doc Letter1.doc My Music Best Songs Every First Songs.mp3 My Song.mp3 # modified 20100102 Hope that makes sense. Thanks, Josh

    Read the article

  • How can I write an XSLT that will recursively include other files?

    - by Eric
    Let's say I have a series of xml files in this format: A.xml: <page> <header>Page A</header> <content>blAh blAh blAh</content> </page> B.xml: <page also-include="A.xml"> <header>Page B</header> <content>Blah Blah Blah</content> </page> Using this XSLT: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/page"> <h1> <xsl:value-of select="header" /> </h1> <p> <xsl:value-of select="content" /> </p> </xsl:template> </xsl:stylesheet> I can turn A.xml into this: <h1> Page A </h1> <p> blAh blAh blAh </p> But how would I make it also turn B.xml into this? <h1> Page B </h1> <p> Blah Blah Blah </p> <p> blAh blAh blAh </p> I know that I need to use document(concat(@also-include,'.xml')) somewhere, but I'm not sure where. Oh, and the catch is, I need this to still work if B were to be included in a third file, C.xml. Any idea as to how to do this?

    Read the article

  • how can we make class with Linked list recursion ...

    - by epsilon_G
    Hi , I'm newbee in The C++ heaven and the OOP, ... I'd like to make some stuffs with the Data structures ... However,I'd like to merge two linked listes ... I made a class before "List" wich contain all what I need to programme something with List ... Add , Display .. The probleme is that I programmed the function "Merge2lists" which give us the third list .. How can I display the third list in the main program after using "Merge2lists" Plz , my prob with the Class and the OOP syntaxe ... try to give me the implementation in the main program ??? Otherwise,How can I apply function given pointer in main program wich declared in class .. Thankx class Liste { private: struct node { int elem ; node *next; }*p; public: LLC(); void Merge2lists (node* a, node * b,node *&result); ~LLC(); }; void List::Merge2lists (node* a, node * b,node *&result) { result = NULL; if (a==NULL) { result=b; return;} else if (b==NULL) { result=a; return;} if (a->elem <= b->elem) { result = a; Merge2lists(a->next, b,result->next); } else { result = b; Merge2lists(a, b->next,result->next); } return; } int main() { liste a ; a.Aff_Val(46); a.Aff_Val(54); a.add_as_first(2); a.add_as_first(1); a.Display(); /*This to displat the elemnts ... Don't care about it it's easy to make*/ list liste2; b.Add(2); b.Add(14); b.Add(16); list result; Merge2lists (a,b,result); /*The probleme is here , how can I use this in my program */

    Read the article

  • Maven: trying to get my submodule's poms to NOT inherit a plugin in the parent

    - by jobrahms
    My project has a parent pom and several submodule poms. I've put a plugin in the parent that is responsible for building our installer distributables (using install4j). It doesn't make sense to have this plugin run on the submodules, so I've put false in the plugin's config, as seen below. The problem is, when I run mvn clean install install4j:compile it cleans, compiles, and runs the install4j plugin on the parent, but then it tries to run it on the child modules and crashes. Here's the plugin config <plugin> <groupId>com.google.code.maven-install4j</groupId> <artifactId>maven-install4j-plugin</artifactId> <version>0.1.1</version> <inherited>false</inherited> <configuration> <executable>${devenv.install4jc}</executable> <configFile>${basedir}/newinstaller/ehd-demo.install4j</configFile> <releaseId>${project.version}</releaseId> <attach>false</attach> <skipOnMissingExecutable>true</skipOnMissingExecutable> </configuration> </plugin> Am I misunderstanding the purpose of inherited=false? What is the correct way to get this to work? I'm using maven 2.2.0.

    Read the article

  • Display `pretty output` of directory content from array

    - by user275074
    Hi, I'm using the following code to get an array of directories and their sub-directories where each contain file type extension: png. It works great but I need to be able to output the results of the array in a list style format e.g. Test - test2.png - test1.png subfolder - test3.png sub sub folder - test4.png etc Code: $filter=".png"; $directory='../test'; $it=new RecursiveDirectoryIterator("$directory"); foreach(new RecursiveIteratorIterator($it) as $file){ if(!((strpos(strtolower($file),$filter))===false)||empty($filter)){ $items[]=preg_replace("#\\\#", "/", $file); } } Example array of results: array ( 0 => '../test/test2.png', 1 => '../test/subfolder/subsubfolder/test3.png', 2 => '../test/subfolder/test3.png', 3 => '../test/test1.png', ) What would be the best way of achieving the desired result?

    Read the article

  • How can invoke a shell to make a new environment to run a make inside another make?

    - by WilliamKF
    I would like in my GNUmakefile to have a target rule that invokes a new shell and then with the clean slate of the new shell invokes a new make. What is the syntax to do this? I tried this but it didn't work: .PHONY: setup setup: shell cd myDir; make; cd .. It gets infinite repeat of the following error: make[1]: Entering directory `/disk4/home/user/parent' shell cd myDir; make; cd .. /bin/sh: shell: command not found make[1]: Entering directory `/disk4/home/user/parent' shell cd myDir; make; cd .. /bin/sh: shell: command not found [...]

    Read the article

  • Whats the python way for recursively setting file permissions?

    - by Geoff
    What's the "python way" to recursively set the owner and group to files in a directory? I could just pass a 'chown -R' command to shell, but I feel like I'm missing something obvious. I'm mucking about with this: import os path = "/tmp/foo" for root, dirs, files in os.walk(path): for momo in dirs: os.chown(momo, 502, 20) This seems to work for setting the directory, but fails when applied to files. I suspect the files are not getting the whole path, so chown fails since it can't find the files. The error is: 'OSError: [Errno 2] No such file or directory: 'foo.html' What am I overlooking here?

    Read the article

  • python: importing modules with incorrect import statements => unexhaustive info from resulting Impor

    - by bbb
    Hi there, I have a funny problem I'd like to ask you guys ('n gals) about. I'm importing some module A that is importing some non-existent module B. Of course this will result in an ImportError. This is what A.py looks like import B Now let's import A >>> import A Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/tmp/importtest/A.py", line 1, in <module> import B ImportError: No module named B Alright, on to the problem. How can I know if this ImportError results from importing A or from some corrupt import inside A without looking at the error's string representation. The difference is that either A is not there or does have incorrect import statements. Hope you can help me out... Cheers bb

    Read the article

  • Where to put a recursive function when following MVC?

    - by Glibly
    Hello, I have a recursive function being used to generate a menu on my site. The function is calling a database for each level of children in the menu, and generating html for them. I've currently put this function in a Model part of the code, however, I feel that generating html in the model goes against the MVC. I didn't put it in a Controller because I didn't want to have database calls or HTML generation there. I didn't put it in a View because I didn't want database calls there either. Is the 'correct' way of tackling this problem to have a Controller call a recursive function in a Model that returns a 2d array representing the menu. Then pass the array to a view which has it's own recursive function for generating html from the array?

    Read the article

  • How to write a recursive function that returns a linked list of nodes, when given a binary tree of n

    - by Jian Lin
    I was once asked of this in an interview: How to write a recursive function that returns a linked list of nodes, when given a binary tree of nodes? (flattening the data) For some reason, I tend to need more than 3 to 5 minutes to solve any recursive problem. Usually, 15 to 20 minutes will be more like it. How could we attack this problem, such as a very systematic way of reaching a solution, so that they can be solved in 3 to 5 minute time frame?

    Read the article

  • What is the proper way to create a recursive entity in the Entity Framework?

    - by Orion Adrian
    I'm currently using VS 2010 RC, and I'm trying to create a model that contains a recursive self-referencing entity. Currently when I import the entity from the model I get an error indicating that the parent property cannot be part of the association because it's set to 'Computed' or 'Identity', though I'm not sure why it does it that way. I've been hand-editing the file to get around that error, but then the model simply doesn't work. What is the proper way to get recursive entities to work in the Entity Framework. CREATE TABLE [dbo].[Appointments]( [AppointmentId] [int] IDENTITY(1,1) NOT NULL, [Description] [nvarchar](1024) NULL, [Start] [datetime] NOT NULL, [End] [datetime] NOT NULL, [Username] [varchar](50) NOT NULL, [RecurrenceRule] [nvarchar](1024) NULL, [RecurrenceState] [varchar](20) NULL, [RecurrenceParentId] [int] NULL, [Annotations] [nvarchar](50) NULL, [Application] [nvarchar](100) NOT NULL, CONSTRAINT [PK_Appointments] PRIMARY KEY CLUSTERED ( [AppointmentId] ASC ) ) GO ALTER TABLE [dbo].[Appointments] WITH CHECK ADD CONSTRAINT [FK_Appointments_ParentAppointments] FOREIGN KEY([RecurrenceParentId]) REFERENCES [dbo].[Appointments] ([AppointmentId]) GO ALTER TABLE [dbo].[Appointments] CHECK CONSTRAINT [FK_Appointments_ParentAppointments] GO

    Read the article

  • Can you make a PHP function recursive without repeating it's name?

    - by alex
    It's always bugged me a recursive function needs to name itself, when a instantiated class can use $this and a static method can use self etc. Is there a similar way to do this in a recursive function without naming it again (just to cut down on maintenance)? Obviously I could use call_user_func or the __FUNCTION__ constant but I would prefer something less ugly. Update Thanks for your answers. I might stick to including the function name for simple functions, and make take the other approaches for anything more complicated.

    Read the article

  • Change a Recursive function that has a for loop in it into an iterative function?

    - by Bill
    So I have this function that I'm trying to convert from a recursive algorithm to an iterative algorithm. I'm not even sure if I have the right subproblems but this seems to determined what I need in the correct way, but recursion can't be used you need to use dynamic programming so I need to change it to iterative bottom up or top down dynamic programming. The basic recursive function looks like this: Recursion(i,j) { if(i>j) return 0; else { //This finds the maximum value for all possible subproblems and returns that for this problem for(int x = i; x < j; x++) { if(some subsection i to x plus recursion(x+1,j) is > current max) max = some subsection i to x plus recursion(x+1,j) } } } This is the general idea, but since recursions typically don't have for loops in them I'm not sure exactly how I would convert this to iterative. Does anyone have any ideas?

    Read the article

  • How can I make a recursive version of my iterative method?

    - by user247679
    Greetings. I am trying to write a recursive function in Java that prints the numbers one through n. (n being the parameter that you send the function.) An iterative solution is pretty straightforward: public static void printNumbers(int n){ for(int i = 1; i <= n; i++){ System.out.println(i); i++; } As a novice programmer, I'm having troubles figuring out how a recursive version of this method would work. Any bright ideas? Thanks for reading my problem!

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >