From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.help Subject: Re: Invoking a function from a list of functions Date: Fri, 09 Nov 2018 15:09:00 +0800 Message-ID: <87sh0a9183.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> References: <20181108230125.GA2179@mail.akwebsoft.com> <87o9azoxdh.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1541771145 32596 195.159.176.226 (9 Nov 2018 13:45:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2018 13:45:45 +0000 (UTC) To: Tim Johnson , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 14:45:41 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL76R-0008Jb-1t for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 14:45:39 +0100 Original-Received: from localhost ([::1]:34195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL78X-0008Gk-JO for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 08:47:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL0wb-0003LX-1i for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 02:11:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL0wW-0005Vv-DZ for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 02:11:04 -0500 Original-Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:41482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gL0wW-0005T5-1A for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 02:11:00 -0500 Original-Received: by mail-pl1-x633.google.com with SMTP id p16-v6so519157plr.8 for ; Thu, 08 Nov 2018 23:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=IHZZLHQS/5ZxbRUFN11PnZHH4/sCrYrh259IYHZv1Is=; b=WlCa4DS8zZ+1NZm6x+FVg9cz8eG77sbM5mwx0MJ9TZTNrjwuGQSBO4Xw7dbclGuWEq 0iTwycGILuSvAShevfLndXKeS57AJLWPbdGr6Rb8Dk9GAA/V5Kc9tQpiHqpkp/PrhhC9 4Bt3i+mkcakVgaChiE/A1WO6SWcMMiYE3OFOIK+5nJkdlOK3Bqvafs1RNNKYDWKt5gCX QmubGylgXj0k7NxehpwWOlKow65cw2QiJ8JolTok6VU9toGSsQP15qG4S/5n37mjcffW MMgbnDnkaQiZs05zYKIDIBpudk5160QMkEVtth8MPnyrIjXTBHGxxVx2+zUzJbR7i98b xpLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=IHZZLHQS/5ZxbRUFN11PnZHH4/sCrYrh259IYHZv1Is=; b=uUCV41kE+7LYylHdff1hnhzr1/qmgAMBU2CG2BciltgHQ6k92P6rlkCo6vwz1d8Kbf RHt83ikisgqXJ5uv1EqOar7mB0wWzhkEKIR3RgkijNOWDH89tRUeJ/jnK5MlA2PQhiRF CkcoReT5lwIsUvuSHNjAbiyPJThhrlwbObpNzH1Io6PVi0F8IXGwT51n8DUm1hkNnsFo bUd22R1IMMNgVVmaedbKr2TzxHNbFBwHQudC8dKEqHF6Gc5LF9oUgbG45K5gNQSRf3eB cRy5gUsroyh8y2cxpqFTqreH5oSBxRbtdMfPAUQOonaLKMkI3knM05YGhrAZ4rWk+hAS aTJQ== X-Gm-Message-State: AGRZ1gKPEGS2oXnGm5dJ4pKpysbge+LnobkMF9V3Yww0YhNTx8oodczW D/92CZwkO4mvLdlm/1QAZhc= X-Google-Smtp-Source: AJdET5dCknPh+GMg36xtl1TSHCl30ixA/jiFtABie6qPqAmpMcK9esiDq5mTlKsj2ZTe1dczpbjzkQ== X-Received: by 2002:a17:902:5590:: with SMTP id g16-v6mr7761834pli.56.1541747457810; Thu, 08 Nov 2018 23:10:57 -0800 (PST) Original-Received: from localhost ([202.94.70.51]) by smtp.gmail.com with ESMTPSA id t77-v6sm11416634pfj.79.2018.11.08.23.10.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 23:10:56 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::633 X-Mailman-Approved-At: Fri, 09 Nov 2018 08:47:16 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:118618 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable All the strength of `mapc`, `mapcar`, `reduce` and other list functions is in your hands. For example, #+begin_src emacs-slip (setq funclist (mapcar #'symbol-function '(forward-line forward-char))) (mapc #'funcall funclist) (cl-mapc #'funcall funclist (make-list (length funclist) 2)) #+end_src You can also take a look at =3Ddash.el=3D. There are many useful list functions there. Best, Ihor Tim Johnson writes: > * Eric Abrahamsen [181108 16:28]: >> Tim Johnson writes: >>=20 >> > Given a list of functions: >> > (setq funcs '(scroll-up-line scroll-down-line)) >> > >> > And assuming that these functions have a similar argument list,=20 >> > I can invoke a function as: >> > >> > (funcall (nth 1 funcs)) >> > ;; or optionally=20 >> > (funcall (nth 1 funcs) 2) >> > >> > That approach is sufficient for my needs at the moment, an example >> > of which might be to cycle through color themes invoked by my own >> > functions. >> > >> > However, in the quest for futher edification I'd welcome URLs to >> > documentation or discussion, as well as any contributions other >> > emacsen might choose to make. Keywords also. >> > >> > I had a heck of a time getting relevant responses from google. I >> > actually don't know what keywords to search with.=20 >>=20 >> It isn't clear to me, at least, what else you might be trying to achieve >> here. Is it more accurately selecting a function from within a list, >> using a keyword? Or cycling through functions in a list? >>=20 >> You'll have a heck of a time getting relevant responses on this list, >> too, unless you tell us what you're after! :) > Thanks for the reply Eric: As I demonstrated on my code examples, > I know how to extract a function from a list and invoke it. > > ... So that's done. Now, iterating thru a list of functions that > might invoke a particular color theme is an example of such an > application and I think I grok that. > > What I am interested in is further discussion whether it be from > replies to this topic or more general topics in this area. I'm > restating that I've had a difficult time finding results from > google.=20 > > -------------------------------------------------------- > That is probably because I don't know the right keywords > or domain-specific terms to use > -------------------------------------------------------- > > This isn't just difficult for emacs/elisp, I've found it difficult > for python functions invoked from lists or dictionaries. (altho > I've employed such methods for years in python) > > So I'm sorry to be so unclear: let me restate the nut and kernel > of my question:=20 > > If I wished to further research this topic using a search engine > what are the keywords that I might feed to google? > > I hope that you now understand what I'm after. > > cheers > --=20 > Tim Johnson > http://www.tj49.com > --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEERZAHPFbUe3JemmzmZHB2Kn2hHYsFAlvlMo0ACgkQZHB2Kn2h HYse+AgAs0/179Ua2dDtGcpc7LlRPYgIk4+PWq9N2XCWv94mvezLknqB6zp96BW6 2E24P7SUAysq3eiH5kHd40nB23Q7Iu7D7iPDIujmQWBRKrTbf7jRzB22wIsQ4wBf t8P0KIGFRKpoP9e0mrWtgG8KwFKLRve0JNJscYtpcmktJt0mUD9p4hv+ugLUYzSY /v1Qc0ZyaLItS+5I8BR5SYfkjgpT1xcC+6ntzcPbqmQody6amDkpzBsXSvXR56Er +p7PLg2GUuz36E1+NRlVz0MJ1hXoMW0D8xaukrqYSTPzXRumuSP6xktakfps8rHS XiX5HWWwZPbKs4eh8oIU7iL4Xl994Q== =twAF -----END PGP SIGNATURE----- --=-=-=--