From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: problem with mapconcat Date: Wed, 03 Mar 2010 23:56:47 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1267685869 30473 80.91.229.12 (4 Mar 2010 06:57:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 4 Mar 2010 06:57:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 04 07:57:45 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nn50D-0007gU-8i for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Mar 2010 07:57:45 +0100 Original-Received: from localhost ([127.0.0.1]:32905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nn50C-0006Gc-Ph for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Mar 2010 01:57:44 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nn4zZ-0006FX-6Y for help-gnu-emacs@gnu.org; Thu, 04 Mar 2010 01:57:05 -0500 Original-Received: from [140.186.70.92] (port=46965 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nn4zX-0006Em-S4 for help-gnu-emacs@gnu.org; Thu, 04 Mar 2010 01:57:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nn4zW-0007la-Vj for help-gnu-emacs@gnu.org; Thu, 04 Mar 2010 01:57:03 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:48281) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nn4zW-0007lS-MV for help-gnu-emacs@gnu.org; Thu, 04 Mar 2010 01:57:02 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Nn4zT-0007Ik-Ez for help-gnu-emacs@gnu.org; Thu, 04 Mar 2010 07:56:59 +0100 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 04 Mar 2010 07:56:59 +0100 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 04 Mar 2010 07:56:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72350 Archived-At: Christian Wittern wrote: > I am trying to build a regex with lisp, which inserts a certain string > into another string between each character, for example "abc" should > turn into "a/b/c". > > With mapconcat, I think this should work: > > (mapconcat 'identity (string-to-list "abc") "/") > > since the description for mapconcat says > > (mapconcat FUNCTION SEQUENCE SEPARATOR) > > However, when I try to evaluate this in Emacs 23.1, here it throws the > following error: > > Debugger entered--Lisp error: (wrong-type-argument sequencep 97) > mapconcat(identity (97 98 99) "/") > eval((mapconcat (quote identity) (string-to-list "abc") "/")) > > I wonder what I am doing wrong or if there is another way to achieve > what I am trying to do. The reason your first attempt failed is that string-to-list returns a list of characters, and identity obviously returns each character -- but mapconcat requires that FUNCTION return a string. As Thamer Mahmoud showed, string-to-list is unnecessary: (mapconcat 'char-to-string "abc" "/") -- Kevin Rodgers Denver, Colorado, USA