From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.help Subject: Re: looping over characters in a string in elisp? Date: Thu, 26 Dec 2002 01:32:33 +0100 Organization: http://purl.org/harder/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1040862949 31137 80.91.224.249 (26 Dec 2002 00:35:49 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 26 Dec 2002 00:35:49 +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 18RM04-000865-00 for ; Thu, 26 Dec 2002 01:35:48 +0100 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 18RLzf-0003nm-04 for gnu-help-gnu-emacs@m.gmane.org; Wed, 25 Dec 2002 19:35:23 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!newsfeed.mathworks.com!news.tele.dk!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; 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:5011 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5011 Roy Smith writes: > I can't figure out how to loop over each character in a string in > elisp (I'm using emacs 20.5.1). I know I can use mapchar to map a > function to each character, but I'm looking for something that lets me > do (essentially): > > (while char in string > (do stuff)) Here's two different ways: (require 'cl) (setq str "Test!") (dolist (char (append str nil)) (print char)) (dotimes (i (length str)) (print (aref str i)))