From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Passing function to mapcar Date: Mon, 02 Sep 2024 11:04:08 +0200 Message-ID: <871q225svr.fsf@gmx.net> References: <7gCipGlilClt_mxSbraoYACoR6rHzQFm-JCI_l8iT9Ql-dSYy5VArUWM5fl2gcKpLfKOnxWiC5VYS0ey7dQTvESkr1c8awVioFwSrJmEM-g=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36579"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 02 11:10:09 2024 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 1sl34a-0009Kw-Q7 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Sep 2024 11:10:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sl345-00056q-BH; Mon, 02 Sep 2024 05:09:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl343-00056c-3p for help-gnu-emacs@gnu.org; Mon, 02 Sep 2024 05:09:35 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl340-0007Ay-VS for help-gnu-emacs@gnu.org; Mon, 02 Sep 2024 05:09:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1725268169; x=1725872969; i=stephen.berman@gmx.net; bh=CU/ggHSQ03j8v2kkK0zcEk2+6UwAVKMFvlD7eURw6GI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=TEThC9OFsU2AFcgEr1NsqBefj917q00x6T99ieNtUogYWU555Iyf3L5C3/5325tu TvTD2PkY+YJ4ag1Uv11nHKaOpwIEjCeM3J1xv9PZciLH3SG1RLI+7F2CKYWlsvojU Ly8oWclMLbBSsmkDEZ2k/f685yuYHLmmaMvsOWkEBpNBzkGnbzlVu8abUjFtLwNyV GUbg/BQjEajRRGgiAew0UDkoHHFGvgfRXwm/n5DIiX0uriKAZQl4ALOiWUaRluK+m vWYfZXFWqZqad5GacGnBN3Y+nrCMOl2Vgc5qZF8w56aAO/0KAdip3HmaaxzudYWgl yZKHGqZrToAl/S6BjA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([94.134.95.111]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MqJqD-1sGbex18J1-00nueC; Mon, 02 Sep 2024 11:04:12 +0200 In-Reply-To: <7gCipGlilClt_mxSbraoYACoR6rHzQFm-JCI_l8iT9Ql-dSYy5VArUWM5fl2gcKpLfKOnxWiC5VYS0ey7dQTvESkr1c8awVioFwSrJmEM-g=@protonmail.com> (Heime's message of "Sun, 01 Sep 2024 23:44:03 +0000") X-Provags-ID: V03:K1:fMKhjCXW3ukHQG72b0d8CQGsAsgvBYKJmHtLnBcfteKfcUPG4N/ M7MnM6tatlhfsSDGjfCusjgMpNCp+Ckh00uCRILFlgviIh9KAZBcZ9Z0Q7xuWMB91+HE982 n+HUE0yEIR9ZkKIRKT7RvtJq132EOfawuZcNyLkOmwt7BZ/nuUq/65R3mgEx1z9tUPVANXy jrBuzNGSe99EoTzlUKmpg== UI-OutboundReport: notjunk:1;M01:P0:T9UaNqJj1s8=;d72fPHX0er+BsiC0AZ80lscMp8b n3AmphQY72IIcypG38bN2IoELsUPX38cIIRDcnAZofcq7UTxtSp0GtNvzHHWjej4m6erd0k3G sTbk1XOl9XZxac4+TlvM74GnjsqiLgDKaa0jXJiOijvrp+5tpOqtkgK7Phtuf4cTgSst1wgwz mHxYME5kiU6ZdNbY+2KnQ8Kpc9g1D+F0Acbtxjtk51y/oqkT7YbHBgKi/RF9PWSSwO5mSGMWV +N7MWORLntLJdnpc+HzC/D25JmCbmY4lUbZYANLrgHVvhWoTz6ust+k06zhY3GW8lVvf8NdId OxdvDsDpHdXvj9kMhvMOOrf5XFb5N/E2l7M6ikJYPSB3URalN5y/JnSc6F2uoeleUz9l+PQ5O 6CJy/1N3BcR3mcVKx4LhuVdwSB5HwKer0J9cOghebCtMxg8gfwkE0Qad1NIvzAsYjxlABDWsG V+aJ1Vv+nRGeQzfFkhr8t9a8gWIIWC/6VSpA68AvR9FJZjS/yNSXBCTJ/XUk0gBK1c0azrIC4 ALNeW8NRd2Ory7AOeVv0jc1hGjKcurQnbDnjec2iemXckKnPhkK8yu+d8EaDAropwuD8hHnUP zuY7ZtG6d7M0lKJ8iYL/z18lAujyFInL0EVjGM1KU68FPnudb4bu4NALy+tTEwBBeqEEbUB/0 W812Vr9ZNJVhbKEU8H7ujBmV7uMjtrTvr3Uv8FpDHZCHqBWPjOB5jJlgyeQsKLkV0nvjTl7xU KMbIliYSsYZpUy3q/TJqSj2X6Ww/ro4rLqk+y53ul8gP67oVJa7coTpvwshr+ijzXEAuLDXu Received-SPF: pass client-ip=212.227.15.15; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147884 Archived-At: On Sun, 01 Sep 2024 23:44:03 +0000 Heime wrot= e: > I am using mapcar to apply the lambda function taking values > in rgb-list as argument c. > > (mapcar (lambda (c) > (min 255 (max 0 (round (* c factor))))) > rgb-list) > > I think that the function used for mapcar should have only a > single argument. Is this correct ? Yes. > What can one do if I want to call a function with more than > a single argument ? > > (defun myfunc (c factor) > (min 255 (max 0 (round (* c factor))))) > > (mapcar myfunc(c factor) rgb-list) If you redefine `myfunc' to make `factor' the first argument and `c' the second, you can use apply-partially; maybe that does what you want: (let ((rgb-list '(37 157 217)) (factor 0.7)) (mapcar (apply-partially #'myfunc factor) rgb-list)) =3D> (26 110 152) (If `factor' is always a single number you don't need to redefine `myfunc', since multiplication is commutative, but then the argument `c' is assigned the value of `factor' in the call to apply-partially and the argument `factor' gets the respective values of `rgb-list', so conceptually it's better to switch the arguments.) Steve Berman