From: Ihor Radchenko <yantar92@gmail.com>
To: Tim Johnson <tim@akwebsoft.com>, help-gnu-emacs@gnu.org
Subject: Re: Invoking a function from a list of functions
Date: Fri, 09 Nov 2018 15:09:00 +0800 [thread overview]
Message-ID: <87sh0a9183.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 3013 bytes --]
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 =dash.el=. There are many useful list
functions there.
Best,
Ihor
Tim Johnson <tim@akwebsoft.com> writes:
> * Eric Abrahamsen <eric@ericabrahamsen.net> [181108 16:28]:
>> Tim Johnson <tim@akwebsoft.com> writes:
>>
>> > Given a list of functions:
>> > (setq funcs '(scroll-up-line scroll-down-line))
>> >
>> > And assuming that these functions have a similar argument list,
>> > I can invoke a function as:
>> >
>> > (funcall (nth 1 funcs))
>> > ;; or optionally
>> > (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.
>>
>> 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?
>>
>> 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.
>
> --------------------------------------------------------
> 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:
>
> 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
> --
> Tim Johnson
> http://www.tj49.com
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
next prev parent reply other threads:[~2018-11-09 7:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-08 23:01 Invoking a function from a list of functions Tim Johnson
2018-11-09 1:25 ` Eric Abrahamsen
2018-11-09 6:03 ` Tim Johnson
2018-11-09 10:30 ` Marcin Borkowski
2018-11-09 11:52 ` Noam Postavsky
2018-11-09 13:12 ` Van L
2018-11-09 16:14 ` Tim Johnson
2018-11-09 14:16 ` Yuri Khan
2018-11-09 16:22 ` Tim Johnson
2018-11-09 16:37 ` Stefan Monnier
[not found] ` <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
2018-11-09 7:09 ` Ihor Radchenko [this message]
2018-11-09 8:58 ` Andreas Röhler
2018-11-09 16:24 ` Tim Johnson
[not found] <mailman.3677.1541718983.1284.help-gnu-emacs@gnu.org>
2018-11-12 5:39 ` Rusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh0a9183.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me \
--to=yantar92@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tim@akwebsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.