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

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

Re: "push" creating circular objects


From: weber
Subject: Re: "push" creating circular objects
Date: Wed, 20 Aug 2008 14:50:08 -0700 (PDT)
User-agent: G2/1.0

On Aug 20, 4:07 pm, Charles Sebold <address@hidden> wrote:
> On 20 Aug 2008, Charles Sebold wrote:
>
> > I just changed it from push to append, with no change in behavior:
>
> Now I tried something even more radical, a completely different approach
> to the problem, just to see what happens.
>
> (defun Textile-list-context (textile-list-tag)
>   "Return list of HTML tags corresponding to list context (ol, ul)."
>   (let ((my-list (delete " " (delete "" (split-string textile-list-tag "")))))
>     (mapcar (lambda (x)
>               (cond
>                ((string= x "#")
>                 "ol")
>                ((string= x "*")
>                 "ul")
>                (t
>                 nil))) my-list)))
>
> _It still returns a circular list._
>
> And it still does the right thing, when I call it from a scratch buffer.
>
> Clearly there is something deep about lists that I don't get right now.
> --
> Charles Sebold                                      20th of August, 2008

Minor variation:

(defun test2 (str)
  (let (my-list)
        (with-temp-buffer
          (insert str)
          (goto-char (point-min))
          (while (not (eobp))
                (cond
                  ((= (char-after) ?#)
                   (push "ol" my-list))
                  ((= (char-after) ?*)
                   (push "ul" my-list)))
                (forward-char 1)))
        my-list))

no need to bind my-list to nil too :)

-hugo


reply via email to

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