From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Using append to create a list from a line of text
Date: Wed, 17 Apr 2013 20:23:20 +0200 [thread overview]
Message-ID: <87ehe96mp3.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: barmar-5FDDC8.12275817042013@news.eternal-september.org
Barry Margolin <barmar@alum.mit.edu> writes:
> In article <87ip3m6vyj.fsf@kuiper.lan.informatimago.com>,
> "Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
>
>> acomber <deedexy@gmail.com> writes:
>>
>> > I want to create a list of words from a line of text delimitted by tabs. I
>> > want to basically split the line into atoms, split by tab.
>> >
>> > The code below is sort of pseudocode but is this the best approach to do
>> > this type of thing?
>> >
>> > Here is my first attempt:-
>> >
>> > (defun get-hdr()
>> > ;obviously point must be positioned on correct line
>> > (let (mylist)
>> > while(not (end-of-line)
>> > while(re-search-forward ("[A-Za-z]+[^\t\n]" nil t)
>> > append (match-string 1) mylist
>> > )
>> > )
>> > )
>> > )
>>
>> Nice, but it's not formatted correctly. I'd avise you to use
>> paredit-mode.
>>
>> Adding and removing newlines where one should, and letting emacs indent
>> the sexp, we get this text:
>>
>>
>> (defun get-hdr()
>> ;; obviously point must be positioned on correct line
>> (let (mylist)
>> while
>> (not (end-of-line)
>> while
>> (re-search-forward ("[A-Za-z]+[^\t\n]" nil t)
>> append
>> (match-string 1)
>> mylist))))
>>
>> Now, two obvious things:
>>
>> 1- undefined variable named `while'. Where does that variable come
>> from?
>>
>> 2- the function `not' is passed three arguments, when it expects only
>> one!
>
> I think you missed that he said this was pseudo-code, not valid Lisp
> code.
Indeed, I missed it. But also, if you write your pseudo code as a
possibly valid lisp form, you can easily make it executable:
http://groups.google.com/group/comp.lang.lisp/msg/a827235ce7466a92
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
next prev parent reply other threads:[~2013-04-17 18:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.24205.1366106299.855.help-gnu-emacs@gnu.org>
2013-04-16 20:51 ` Using append to create a list from a line of text Pascal J. Bourguignon
2013-04-17 16:27 ` Barry Margolin
2013-04-17 18:23 ` Pascal J. Bourguignon [this message]
2013-04-16 9:58 acomber
2013-04-16 10:05 ` Christopher Schmidt
2013-04-16 13:10 ` Drew Adams
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=87ehe96mp3.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.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).