help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to cast an imperative loop into a readable recursive function ?


From: Katalin Sinkov
Subject: Re: How to cast an imperative loop into a readable recursive function ?
Date: Thu, 2 Dec 2010 23:06:19 -0800 (PST)
User-agent: G2/1.0

On Dec 2, 7:30 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
> Katalin Sinkov <lispstyl...@gmail.com> writes:
> > what I forgot to mention was that it should be possible to view the
> > subseries problem in a way that I dont have to go thru a loop but use
> > recursive definitions.
>
> The problem is still very confusing, but it sounds to me like maybe
> you want something like (untested):

it has been quite helpful. I need to give a function name to be able
to recurse.

>
>    (defun foo (n str)
>       (let ((s ...) (l ...) (p ...)                      ;;; s=start l=length 
>  p=??????
>            ;; after reading the (s=2 l=4) prefix above,  ;;; this is exactly 
> what should happen
>            ;; p points past the end of it                ;;;  and how mine 
> worked (pseudocode)
>            (if (< n l)                                   ;;; in {} ..  if ( 
> (n-s) < l )
>               (aref str (+ p n))                         ;;; (aref str  (- n 
> s))
>              (foo (- n l) (substring str (+ p l)))))))   ;;; I dont think i 
> need substring if
                                                           ;;;  I set
a pointer.

What i find very confusing is this :

right now I have lots of globals in emacs.

all the data is in a file opened in emacs.

At some stage there will confusion and readability issue.

What strategies are there to grapple with this issue ?

At the moment, it appears that I can just copy parts of the buffer
(file) into a string type variable that is temporary and is
deallocated as soon as the function exits.

what is a recommended emacs command to copy parts of buffer into a
temporary local string variable ?

I should place stars around all global variable identifiers.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]