From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Corwin Brust Newsgroups: gmane.emacs.help Subject: Re: count char in string [The Emacs Challenge Competition - round 2, with fallout] Date: Wed, 28 Oct 2020 03:04:09 -0500 Message-ID: References: <87r1pj41wa.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39609"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 28 09:05:05 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXgS8-000AB0-Vx for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 28 Oct 2020 09:05:04 +0100 Original-Received: from localhost ([::1]:49112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXgS8-0002Xp-1a for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 28 Oct 2020 04:05:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXgRS-0002XS-6Y for help-gnu-emacs@gnu.org; Wed, 28 Oct 2020 04:04:22 -0400 Original-Received: from mail-ed1-f51.google.com ([209.85.208.51]:39639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXgRQ-0004rj-FR for help-gnu-emacs@gnu.org; Wed, 28 Oct 2020 04:04:21 -0400 Original-Received: by mail-ed1-f51.google.com with SMTP id a6so4142730edx.6 for ; Wed, 28 Oct 2020 01:04:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=e3pUn5kT54TDnZJPGeCvhkGtrSQ/hFcajHETxyKJNg0=; b=d0ft/is+qctl3kZvRCaQexFP9Hi78Lga7BzOJ6KCUe3Vpv+i0NUADnih+gbGJaNktD u3rIY+94U5uGg0ji0Io1HC7+/GXjItItf/5uxAn2Ez2izK0l55T8EuQ2FMEEF7ojtu+v rvFB5lba+nEy+SoR6YqW9j9+yA8zdbeRVz5Teeadb3JqBbIPtTrhtBTpzhzXSFtlPG8n L+Tzjod3f0tk5ywL9Cid+CCRALjyCQhkjM5Q++XtKjxEYEhpOJu7SwMK+9QAFj7wxNJJ 2s98poU/Ga0k4uIhEsYIAZz+maRELIU4mo8pQ0y4buCpBkyQSJJYC2aSHS+1bka1h4Nl Zekw== X-Gm-Message-State: AOAM532uncNnwQEUW0yNDIk2sa4vk+k9vIenI+HEN0jZmIAiVI4X2BYa OqTDYpdP5aC6C7jWdQx5EtU4FLfzeRlYdDh2l+U= X-Google-Smtp-Source: ABdhPJxbpcxZo11QT3/1LZ9Y2Foe/jrNDqlo5O3vdkXipyI5lx8E3I6CudtMErt3FgGoNli1yost2nttiLPf8ysxD3w= X-Received: by 2002:a05:6402:8cc:: with SMTP id d12mr2383346edz.134.1603872258964; Wed, 28 Oct 2020 01:04:18 -0700 (PDT) In-Reply-To: <87r1pj41wa.fsf@zoho.eu> Received-SPF: pass client-ip=209.85.208.51; envelope-from=mplscorwin@gmail.com; helo=mail-ed1-f51.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/28 04:04:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124777 Archived-At: 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 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) ;; =E2=87=92 2 Cheers! Corwin