From: Katalin Sinkov <lispstylist@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to cast an imperative loop into a readable recursive function ?
Date: Thu, 2 Dec 2010 23:37:20 -0800 (PST) [thread overview]
Message-ID: <eba8a9c1-e209-4372-9c88-77a6d9c76de1@a17g2000yql.googlegroups.com> (raw)
In-Reply-To: 87ipzbpgft.fsf@kuiper.lan.informatimago.com
On Dec 2, 9:35 pm, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> Katalin Sinkov <lispstyl...@gmail.com> writes:
> > Take a look at my lisp code. it can be modified simply to run it and
> > it runs in an emacs "ide".
>
> No it does not.
>
> First, it's lacking a parenthesis.
>
> You should get paredit.el, and activate the paredit-mode to edit lisp
> sources. See how lisp code is indented, and let emacs and paredit
> indent it for you, and place the parentheses for you. This will produce
> lisp code that is more readable, and you will be able to copy-and-paste
> sexps "structurally", with much less risk of losing parentheses.
>
> Then, if we add the obvious missing parenthesis, and try to evaluate
> your code:
>
> (let ((char_skips (- n s) ))
> (while (not (= char_skips 0))
> (progn
> (if (<= char_skips (+ l -1) )
> (progn
> (forward-char char_skips)
> (setq char_skips 0))
> (progn
> (forward-char l)
>
> (forward-search-regexp "(s=###l=###)" nil nil nil) ; put in an if
> ;; and else block to test if FAIL
> (setq s (match-string 0))
> (setq l (match-string 0))
>
> (setq char_skips (- n s) ))))))
>
> we get the following error:
>
> Debugger entered--Lisp error: (void-variable n)
> (- n s)
> (let ((char_skips ...)) (while (not ...) (progn ...)))
> eval((let ((char_skips ...)) (while (not ...) (progn ...))))
> eval-last-sexp-1(nil)
> eval-last-sexp(nil)
> call-interactively(eval-last-sexp nil nil)
>
> If you want us to help, please provide working stand alone code, with
> test data.
>
> (By the way, my emacs "23.2.1" doesn't have a forward-search-regexp
> function).
search-forward-regexp
more later tomorrow
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
prev parent reply other threads:[~2010-12-03 7:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 1:50 How to cast an imperative loop into a readable recursive function ? Katalin Sinkov
2010-12-03 2:17 ` Paul Rubin
[not found] ` <8a5ef1e1-aab3-47bd-80e3-081f8dc65b0e@c39g2000yqi.googlegroups.com>
[not found] ` <84a24d31-6379-4b81-ac65-b0d8642ab7da@37g2000prx.googlegroups.com>
2010-12-03 3:30 ` Paul Rubin
[not found] ` <0c1c00c1-61ef-42be-a2d3-db1ff31035e8@29g2000yqq.googlegroups.com>
2010-12-03 7:29 ` Paul Rubin
2010-12-03 9:44 ` Tim Bradshaw
2010-12-03 2:48 ` RG
2010-12-03 3:12 ` Katalin Sinkov
[not found] ` <7xk4jrmtmg.fsf@ruckus.brouhaha.com>
2010-12-03 3:22 ` Katalin Sinkov
[not found] ` <87ipzbpgft.fsf@kuiper.lan.informatimago.com>
2010-12-03 7:37 ` Katalin Sinkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eba8a9c1-e209-4372-9c88-77a6d9c76de1@a17g2000yql.googlegroups.com \
--to=lispstylist@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).