|
From: | Corwin Brust |
Subject: | Re: count char in string [The Emacs Challenge Competition - round 2, with fallout] |
Date: | Wed, 28 Oct 2020 03:04:09 -0500 |
We who are about to be educated salute you ;) On Tue, Oct 27, 2020 at 7:42 PM Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote: > > round 2: > > Very simple: we are looking for a function that returns the number of > occurrences of a char in a string. (defun count-char-in-string (string char) "Return the number of occurances of CHAR in STRING." (seq-count (apply-partially 'eq char) (seq-into string 'list))) (count-char-in-string "hii" ?I) ;; ⇒ 2 Cheers! Corwin
[Prev in Thread] | Current Thread | [Next in Thread] |