From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: brendan.halpin@ul.ie (Brendan Halpin) Newsgroups: gmane.emacs.help Subject: Re: How to count the number of occurrences of a character in a string? Date: Tue, 13 Oct 2015 21:46:26 +0100 Message-ID: <87wpuqxzrx.fsf@ul.ie> References: <874mhvq3b2.fsf@mbork.pl> <8337xezpdc.fsf@gnu.org> <83vbaay4dd.fsf@gnu.org> Reply-To: brendan.halpin@ul.ie NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444769487 19498 80.91.229.3 (13 Oct 2015 20:51:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Oct 2015 20:51:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 13 22:51:27 2015 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 1Zm6Xd-0006B3-LN for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Oct 2015 22:51:25 +0200 Original-Received: from localhost ([::1]:39292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zm6Xc-0004WY-Ot for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Oct 2015 16:51:24 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 16 Original-X-Trace: individual.net tbdoYBSA+yWyMwn/HuNzlweU7U/eoprMSsb/OF/iyToDjhqmJ4 Cancel-Lock: sha1:Wz76XR236pyngh/aUOe+6Uzq39I= sha1:W/nzTdF6BmnaAqzNjPQQ5SecxU0= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:215340 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:107624 Archived-At: On Tue, Oct 13 2015, Eli Zaretskii wrote: > Also, did you actually try 'mapc', per my second suggestion? Why not mapcar? (defun test (str char) (apply '+ (mapcar (lambda (x) (if (= x char) 1 0)) str))) B -- Brendan Halpin, Head, Department of Sociology, University of Limerick, Ireland Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F1-002 x 3147 mailto:brendan.halpin@ul.ie ULSociology on Facebook: http://on.fb.me/fjIK9t http://teaching.sociology.ul.ie/bhalpin/wordpress twitter:@ULSociology