Re: Scope Question



dstein64 wrote:
Suppose I have a recursive function that is searching for elements in
a tree. How can I store a list such that it is not reset on each
recursive call to the search function?

In general, how can I initialize a variable within a function that
will not be reset on each recursive call to that function? I hope my
question is clear. If not, please let me know. Thanks.
This counter function should give you an idea:
(let ((count 0))
(defun counter ()
(incf count)))

(that is, make it a closure)
If your recursive function was in a LABELS, you would bind your
variable outside of the LABELS form. Implementing the function with a
locally defined function would probably be best because it means you
might need to do less setup/cleanup.
.



Relevant Pages

  • Re: Address bar Searches
    ... restores the various search function entries and certain prefix values to ... the Search from the Address bar section to be sure you've got ... and then click on Reset Web Settings. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Easy newbie Canon Rebel XT 1st questions
    ... fav local store they won't let me return a Rebel (or maybe not a D70 ... format a CF card with Auto Reset turned, which are my own cards since none comes with the XT, the numbers reset to 0001, as you say. ... I agree with you that my allegedly expert store manager needs to spruce up his techie knowledge. ...
    (rec.photo.digital.slr-systems)
  • Re: Help with programming on HP49G+
    ... The first list of NOVALs is for the Reset values, ... The program doesn't store the ... THEN EVAL \-> Rente Inv Scrap N Skat Afskr ...
    (comp.sys.hp48)
  • Re: Determining State of "set case"
    ... I want to be able to store and reset this value after calling functions that ... the purpose of their string matching. ...
    (comp.protocols.kermit.misc)
  • Re: Resetting Default Printer
    ... If it's a matter of setting then changing back, store the current default printer's name. ... ms mvp, visual basic ... "John Simpson" wrote in message ... This does not reset to the default printer. ...
    (microsoft.public.vb.general.discussion)