From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: How to parse a string? Date: 01 May 2003 23:10:21 +0200 Organization: informatimago.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87fznygypu.fsf@thalassa.informatimago.com> References: <87ade7d023.fsf@noos.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1051823698 19839 80.91.224.249 (1 May 2003 21:14:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 1 May 2003 21:14:58 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Thu May 01 23:14:56 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19BLOJ-00059e-00 for ; Thu, 01 May 2003 23:14:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19BLPK-0003Bz-09 for gnu-help-gnu-emacs@m.gmane.org; Thu, 01 May 2003 17:15:58 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!thalassa.informatimago.COM!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-NNTP-Posting-Host: thalassa.informatimago.com (195.114.85.198) Original-X-Trace: fu-berlin.de 1051823422 13696349 195.114.85.198 (16 [41911]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Xref: shelby.stanford.edu gnu.emacs.help:112637 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9133 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9133 Francois Fleuret writes: > Hi, > > Greg Hill wrote on 01 May 2003 02:54:20 MET: > > > (let ((instring "10 20 wordA wordB wordC")) > > (setq instring (split-string instring)) > > (append (list (string-to-number (pop instring)) > > (string-to-number (pop instring))) > > instring)) > > Thanks a lot! > > But is there a generic way to do such a thing ? No scanf equivalent > around ? > > FF Just encapsulate the line with '( ... ): (defun scanf (string) ;; no need to specify the format and the variable, "We return a list of item scanned from the string." (read (concat "( " string " )"))) (dolist (item (scanf "10 20 3.33 wordA wordB wordC")) (show item (type-of item))) ==> (10 integer) ==> (20 integer) ==> (3.33 float) ==> (wordA symbol) ==> (wordB symbol) ==> (wordC symbol) -- __Pascal_Bourguignon__ http://www.informatimago.com/ ---------------------------------------------------------------------- Do not adjust your mind, there is a fault in reality.