help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to count the number of occurrences of a character in a string?


From: Brendan Halpin
Subject: Re: How to count the number of occurrences of a character in a string?
Date: Tue, 13 Oct 2015 21:46:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]