From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Using append to create a list from a line of text Date: Wed, 17 Apr 2013 20:23:20 +0200 Organization: Informatimago Message-ID: <87ehe96mp3.fsf@kuiper.lan.informatimago.com> References: <87ip3m6vyj.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1366223046 19998 80.91.229.3 (17 Apr 2013 18:24:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Apr 2013 18:24:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 17 20:24:10 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1USX1e-0000BK-7F for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Apr 2013 20:24:10 +0200 Original-Received: from localhost ([::1]:34734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USX1d-0000xh-OR for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Apr 2013 14:24:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USX13-0000Wf-8P for help-gnu-emacs@gnu.org; Wed, 17 Apr 2013 14:23:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USX11-0002b9-8L for help-gnu-emacs@gnu.org; Wed, 17 Apr 2013 14:23:33 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:48498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USX11-0002ay-2M for help-gnu-emacs@gnu.org; Wed, 17 Apr 2013 14:23:31 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1USX0v-0007Ue-RP for help-gnu-emacs@gnu.org; Wed, 17 Apr 2013 20:23:25 +0200 Original-Received: from amontsouris-651-1-15-231.w90-46.abo.wanadoo.fr ([90.46.106.231]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Apr 2013 20:23:25 +0200 Original-Received: from pjb by amontsouris-651-1-15-231.w90-46.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Apr 2013 20:23:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: amontsouris-651-1-15-231.w90-46.abo.wanadoo.fr Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:NzY5MGE4N2ZiZTkxYzcxZjFkMTYxNWM3MzQzYjQ1NTFhY2ZmODU5Nw== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90214 Archived-At: Barry Margolin writes: > In article <87ip3m6vyj.fsf@kuiper.lan.informatimago.com>, > "Pascal J. Bourguignon" wrote: > >> acomber 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 {}.