From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Hill Newsgroups: gmane.emacs.help Subject: Re: a function for string splitting Date: Tue, 26 Nov 2002 12:03:36 -0800 Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <15843.33347.536168.30597@localhost.localdomain> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Trace: main.gmane.org 1038341254 18060 80.91.224.249 (26 Nov 2002 20:07:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 26 Nov 2002 20:07:34 +0000 (UTC) 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 18GlzX-0004h1-00 for ; Tue, 26 Nov 2002 21:07:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18Gm1J-00086v-00; Tue, 26 Nov 2002 15:09:21 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18GlzP-0007Jr-00 for help-gnu-emacs@gnu.org; Tue, 26 Nov 2002 15:07:23 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18GlzL-0007FR-00 for help-gnu-emacs@gnu.org; Tue, 26 Nov 2002 15:07:21 -0500 Original-Received: from renfield.synergymicro.com ([153.105.4.30] helo=synergymicro.com) by monty-python.gnu.org with esmtp (Exim 4.10) id 18GlwI-0006Yv-00 for help-gnu-emacs@gnu.org; Tue, 26 Nov 2002 15:04:10 -0500 Original-Received: from synergy.synergy.encinitas.ca.us ([153.105.4.29]) by synergymicro.com (8.9.3/8.9.3) with ESMTP id MAA30224; Tue, 26 Nov 2002 12:05:49 -0800 Original-Received: from [198.17.100.22] (G-Hill-Mac [198.17.100.22]) by synergy.synergy.encinitas.ca.us (8.9.3/8.8.7) with ESMTP id MAA30739; Tue, 26 Nov 2002 12:04:18 -0800 In-Reply-To: <15843.33347.536168.30597@localhost.localdomain> Original-To: "Luis O. Silva" , help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:4064 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:4064 At 5:16 PM +0300 11/26/02, Luis O. Silva wrote: >Dear Emacs community, > >I'm writing a function for translating dates in the form of a >string into Spanish and Russian. For example, you have: > >"Thu, 21 Nov 2002 16:05:50 -0600 (CST)" > >Within my function I used a `let' expression of the form: > >(let ((day (substring "Thu, 21 Nov 2002 16:05:50 -0600 (CST)" 0 3)) > (month (substring "Thu, 21 Nov 2002 16:05:50 -0600 (CST)" 8 11))) > ...) > >All works fine provided that there isn't any date with >one-digit day, i. e., "Fri, 8 Nov 2002 11:56:37 -0500 (CST)" > >My question is what function I could use for correctly >splitting the string. Luis, Give something like this a try: (let* ((split-date (split-string "Thu, 21 Nov 2002 16:05:50 -0600 (CST)" " ")) ((day-of-week (elt split-date 0)) ((day-of-month (elt split-date 1)) ((month (elt split-date 2)) ...) Be sure to use let* instead of let, since let does not guarentee the order of evaluation, and you always want split-date to be evaluated first. --Greg