Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.tc.cornell.edu!news3.cac.psu.edu!howland.erols.net!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.mathworks.com!newsfeed.internetmci.com!btnet!netcom.net.uk!netcom.com!vfr750
From: vfr750@netcom.com (Will Hartung)
Subject: Bad Idiom?
Message-ID: <vfr750E3oAzr.I5@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Date: Wed, 8 Jan 1997 04:55:03 GMT
Lines: 50
Sender: vfr750@netcom8.netcom.com

Hi All!

Spending some precious moments away from Baywatch, I was playing about
with some code. A function that does list traversal and changes as we
go.

(defun func (x)
    (let* ((func-helper #'(lambda (y)
                            (if (not (null y))
                               (cons (1+ (car y)) 
                                     (func-helper (cdr y)))))))
    (func-helper x)))

Now, in Scheme, we have (letrec ...) which does these kinds of
structures just peachy. But in ACL Lite for Windows, I get a warning
that FUNC-HELPER is not defined and will be treated as dynamic.
Technically, this shouldn't be an issue at runtime, because by the
time we get around to needing FUNC-HELPER, it will, indeed, be bound to
my little lambda.

In most Scheme texts, this kind of list traversing idiom seems pretty
common. The authors really love this stuff. And I'm generally fond of
it as well, save for my code gets pretty deeply nested and starts to
look bad even to the pretty-printer.

Is this the common idiom for list traversal in CL? Is their some other
CL bit that I (somehow) managed to miss that sort of automates this
kind of process? (do ...) is popular, but not for lists. Maybe
something with (loop ...) or (for ...) or who knows.

The CL iteration facilities may be rich, but I find them a touch
difficult grab a hold of. They're a far cry from FOR i= 1 to 100. You
may be able to DO this easily, but have you ever seen the help page in
ACL regarding FOR (see loop) and LOOP (...ummmm....its long!).

Of course, this is the story of my LISP life, it seems.

Anyway, since ACL complained, I'm wont to think that my little
function is Bad Form. Idiomatically Challenged.

So, I'm hoping for what Real Lisp programmers do, so I can pick up
more Lisp Idioms and therefore become a better, and more knowledgable
Lisp Idiot! :-)

Thanx for any help!

-- 
Will Hartung - Rancho Santa Margarita. It's a dry heat. vfr750@netcom.com
1990 VFR750 - VFR=Very Red    "Ho, HaHa, Dodge, Parry, Spin, HA! THRUST!"
1993 Explorer - Cage? Hell, it's a prison.                    -D. Duck
