[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Invoking a function from a list of functions
From: |
Ihor Radchenko |
Subject: |
Re: Invoking a function from a list of functions |
Date: |
Fri, 09 Nov 2018 15:09:00 +0800 |
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
>
signature.asc
Description: PGP signature
Message not available
- Re: Invoking a function from a list of functions,
Ihor Radchenko <=
Re: Invoking a function from a list of functions, Andreas Röhler, 2018/11/09
- Re: Invoking a function from a list of functions, Rusi, 2018/11/12
- [OFFTOPIC] Re: Invoking a function from a list of functions, Stefan Monnier, 2018/11/12
- Message not available
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, Rusi, 2018/11/15
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, James K. Lowden, 2018/11/16
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, Rusi, 2018/11/17
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, James K. Lowden, 2018/11/19
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, Stefan Monnier, 2018/11/19
- Re: [OFFTOPIC] Re: Invoking a function from a list of functions, Amin Bandali, 2018/11/20