all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Invoking a function from a list of functions
@ 2018-11-08 23:01 Tim Johnson
  2018-11-09  1:25 ` Eric Abrahamsen
  2018-11-09  8:58 ` Andreas Röhler
  0 siblings, 2 replies; 14+ messages in thread
From: Tim Johnson @ 2018-11-08 23:01 UTC (permalink / raw)
  To: Emacs

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. 

thanks
GNU Emacs 26.1 GTK+ Version, Ubuntu 16.04

-- 
Tim Johnson
http://www.tj49.com



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  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
       [not found]   ` <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
  2018-11-09  8:58 ` Andreas Röhler
  1 sibling, 2 replies; 14+ messages in thread
From: Eric Abrahamsen @ 2018-11-09  1:25 UTC (permalink / raw)
  To: help-gnu-emacs

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! :)




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09  1:25 ` Eric Abrahamsen
@ 2018-11-09  6:03   ` Tim Johnson
  2018-11-09 10:30     ` Marcin Borkowski
                       ` (2 more replies)
       [not found]   ` <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
  1 sibling, 3 replies; 14+ messages in thread
From: Tim Johnson @ 2018-11-09  6:03 UTC (permalink / raw)
  To: help-gnu-emacs

* 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



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
       [not found]   ` <mailman.3694.1541743398.1284.help-gnu-emacs@gnu.org>
@ 2018-11-09  7:09     ` Ihor Radchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Ihor Radchenko @ 2018-11-09  7:09 UTC (permalink / raw)
  To: Tim Johnson, help-gnu-emacs

[-- 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 --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  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  8:58 ` Andreas Röhler
  2018-11-09 16:24   ` Tim Johnson
  1 sibling, 1 reply; 14+ messages in thread
From: Andreas Röhler @ 2018-11-09  8:58 UTC (permalink / raw)
  To: help-gnu-emacs

On 09.11.2018 00:01, Tim Johnson wrote:
> 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.
> 
> thanks
> GNU Emacs 26.1 GTK+ Version, Ubuntu 16.04
> 


Maybe that way:

(defun foo ()
   (message "%s" "foo"))

(defun bar ()
   (message "%s" "bar"))

(setq my-list-of-functions (list 'foo 'bar))

(funcall (nth 1 my-list-of-functions))

;;;;;

The point is to hand over functions as symbols, not their value



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09  6:03   ` Tim Johnson
@ 2018-11-09 10:30     ` Marcin Borkowski
  2018-11-09 11:52     ` Noam Postavsky
  2018-11-09 14:16     ` Yuri Khan
  2 siblings, 0 replies; 14+ messages in thread
From: Marcin Borkowski @ 2018-11-09 10:30 UTC (permalink / raw)
  To: Tim Johnson; +Cc: help-gnu-emacs


On 2018-11-09, at 07:03, Tim Johnson <tim@akwebsoft.com> wrote:

> * 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.

Just guessing:

first-class functions/closures?
functions as data?
dynamic function calling?

Hth,

-- 
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  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
  2 siblings, 2 replies; 14+ messages in thread
From: Noam Postavsky @ 2018-11-09 11:52 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

On Fri, 9 Nov 2018 at 01:03, Tim Johnson <tim@akwebsoft.com> wrote:

>   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.

>   If I wished to further research this topic

What is "this topic"? Extracting a value from a list? Calling a function?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09 11:52     ` Noam Postavsky
@ 2018-11-09 13:12       ` Van L
  2018-11-09 16:14       ` Tim Johnson
  1 sibling, 0 replies; 14+ messages in thread
From: Van L @ 2018-11-09 13:12 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list


> What is "this topic"? Extracting a value from a list? Calling a function?

Given a list of functions (fa fb fc ...), pick one to call?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09  6:03   ` Tim Johnson
  2018-11-09 10:30     ` Marcin Borkowski
  2018-11-09 11:52     ` Noam Postavsky
@ 2018-11-09 14:16     ` Yuri Khan
  2018-11-09 16:22       ` Tim Johnson
  2 siblings, 1 reply; 14+ messages in thread
From: Yuri Khan @ 2018-11-09 14:16 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, Nov 9, 2018 at 1:03 PM Tim Johnson <tim@akwebsoft.com> wrote:

> > > 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)

>   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)
>
>   If I wished to further research this topic using a search engine
>   what are the keywords that I might feed to google?

The term you are looking for is “first-class functions”. This refers
to passing functions as arguments to other functions, returning
functions out of functions, storing functions in variables and data
structures, and otherwise treating functions the same way as other
values.

A related term, but from object-oriented programming, is “virtual
method”. This is a narrower concept, that you might want to call
different implementations of a function depending on the type of its
argument.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09 11:52     ` Noam Postavsky
  2018-11-09 13:12       ` Van L
@ 2018-11-09 16:14       ` Tim Johnson
  1 sibling, 0 replies; 14+ messages in thread
From: Tim Johnson @ 2018-11-09 16:14 UTC (permalink / raw)
  To: help-gnu-emacs

* Noam Postavsky <npostavs@gmail.com> [181109 03:05]:
> On Fri, 9 Nov 2018 at 01:03, Tim Johnson <tim@akwebsoft.com> wrote:
> 
> >   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.
> 
> >   If I wished to further research this topic
> 
> What is "this topic"? Extracting a value from a list? Calling a function?
> 
 Yup.
-- 
Tim Johnson
http://www.tj49.com



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09 14:16     ` Yuri Khan
@ 2018-11-09 16:22       ` Tim Johnson
  2018-11-09 16:37         ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Tim Johnson @ 2018-11-09 16:22 UTC (permalink / raw)
  To: help-gnu-emacs

* Yuri Khan <yurivkhan@gmail.com> [181109 05:28]:
> On Fri, Nov 9, 2018 at 1:03 PM Tim Johnson <tim@akwebsoft.com> wrote:
> 
> > > > 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)
> 
> >   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)
> >
> >   If I wished to further research this topic using a search engine
> >   what are the keywords that I might feed to google?
> 
> The term you are looking for is “first-class functions”. This refers
> to passing functions as arguments to other functions, returning
> functions out of functions, storing functions in variables and data
> structures, and otherwise treating functions the same way as other
> values.

  That is exactly correct, yet I find nothing on this topic using 
  “first-class functions” as a keyword/phrase.

 This obscurity is shared by python. The 'list-or-dictionary-of- functions 
 approach that I've used for years in python is just as
 hard to search for. I believe I also used that tactic in C back
 when I did GUI programming, but it has been so very long and I'm so
 very retired ... :)

> A related term, but from object-oriented programming, is “virtual
> method”. This is a narrower concept, that you might want to call
> different implementations of a function depending on the type of its
> argument.
> 

 thanks

-- 
Tim Johnson
http://www.tj49.com



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09  8:58 ` Andreas Röhler
@ 2018-11-09 16:24   ` Tim Johnson
  0 siblings, 0 replies; 14+ messages in thread
From: Tim Johnson @ 2018-11-09 16:24 UTC (permalink / raw)
  To: help-gnu-emacs

* Andreas Röhler <andreas.roehler@easy-emacs.de> [181109 00:02]:
> On 09.11.2018 00:01, Tim Johnson wrote:
> > 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.
> > 
> > thanks
> > GNU Emacs 26.1 GTK+ Version, Ubuntu 16.04
> > 
> 
> 
> Maybe that way:
> 
> (defun foo ()
>   (message "%s" "foo"))
> 
> (defun bar ()
>   (message "%s" "bar"))
> 
> (setq my-list-of-functions (list 'foo 'bar))
> 
> (funcall (nth 1 my-list-of-functions))
> 
> ;;;;;
> 
> The point is to hand over functions as symbols, not their value
  And in Python, if you evaluate a function without the succeeding
  parens: foo vs. foo() 
  you get an address. Same with C/C++ - if I recall correctly.

-- 
Tim Johnson
http://www.tj49.com



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
  2018-11-09 16:22       ` Tim Johnson
@ 2018-11-09 16:37         ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2018-11-09 16:37 UTC (permalink / raw)
  To: help-gnu-emacs

>   That is exactly correct, yet I find nothing on this topic using 
>   “first-class functions” as a keyword/phrase.

I'm not sure exactly what kind of information you're looking for about
that, but maybe other related keywords might be "indirect function call"
(i.e. `funcall`) and "higher-order function" (which is the term used to
denote the functions that manipulate other functions, such as `mapcar`).


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Invoking a function from a list of functions
       [not found] <mailman.3677.1541718983.1284.help-gnu-emacs@gnu.org>
@ 2018-11-12  5:39 ` Rusi
  0 siblings, 0 replies; 14+ messages in thread
From: Rusi @ 2018-11-12  5:39 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan and Yuri have pointed you to the search terms “higher order” and “first class” functions.  The wider umbrella term is functional programming (FP).
Unfortunately this has become a cult with more malarkey than stuff of late especially after increasing mainstreaming of the FP language Haskell.
IOW there is the irony: from 50 to 25 years ago when FP was academic arcana, the ideas were more accessible than today when the direction invariably tilts towards Haskell: which is somewhat like using a missile to kill a fly.
Me: After having tried many options for teaching programming, Ive personally returned to gofer http://blog.languager.org/2014/09/pugofer.html which is a tiny early Haskell dialect, better for pedagogic purposes than the current behemoth: Some reasons: https://stackoverflow.com/questions/25855507/are-typeclasses-essential/25880674#25880674

But while gofer is ok for students under my supervision it is not a reasonable suggestion across the net

Some more generally reasonable/accessible suggestions:

1. Scheme is very much a lisp (except the Lisp-1 Lisp-2 minor mess https://en.wikipedia.org/wiki/Common_Lisp#The_function_namespace )
and unlike (E)Lisp tries hard to be a propah FPL.
The original scheme text https://mitpress.mit.edu/sites/default/files/sicp/index.html is considered a programming classic by many.
I dont like it much -- http://blog.languager.org/2013/08/applying-si-on-sicp.html shows why scheme though more powerful than FPLs is not properly appreciated even by its authors. Felleisen and Friedman I much prefer to SICP
https://www.htdp.org/2003-09-26/Book/
https://www.cs.unm.edu/~williams/cs357/springer-friedman.pdf

2. APL When we were kids Lisp and APL were the two defacto FPLs.
Today Lisp has stopped being considered an FPL
http://blog.languager.org/2015/04/cs-history-1.html

And APL has fallen off the radar... unfortunate. From your single example — (funcall (nth 1 funcs))  — I assume you are sensing that short expressions can be amazingly powerful and want to learn how to do more of that. Look at https://aplwiki.com/FinnAplIdiomLibrary for more such APL examples [Beware! Head can explode]

3. Python: CS degree students it's reasonable to push through them a dozen different languages so that they understand different paradigms in their most optimal setting. People self learning or with less time etc this may be unpleasant/formidable.  And since you seem familiar with python there are also these two python options.
3a SICP in Python
https://wizardforcel.gitbooks.io/sicp-in-python/content/
http://www-inst.eecs.berkeley.edu/~cs61a/sp12/book/
3b Functional programming in python https://www.amazon.com/Functional-Python-Programming-Steven-Lott/dp/1784396990
[Disclaimer I have not delved into either of these so you spend your time at your risk]

Summary: If you wanted to learn Portuguese you could do it anywhere — NY, London Delhi Tokyo.  However staying in Lisbon or Rio de Janeiro will give you more success (presumably!). Python copied its list comprehensions from haskell so in principle one should be able to write (most) Haskell comprehensions in python.  But in the python world you will find universal dissuasion — "comprehensions are hard; first learn to write for-loops..." etc.
So paradoxically the best way to do comprehensions in python is by learning them out of python… Likewise FP in (E)Lisp

tl;dr: ‘(funcall (nth 1 funcs)) ’ is an example of FP style. Lisp/python can be used (for the most part) as an FPL. The cultural questions are the bigger impediment than the technical/factual ones

FP can be language independent… may be too laconic for a beginner! Consider these a list of search terms.

http://blog.languager.org/2012/10/functional-programming-lost-booty.html
http://blog.languager.org/2015/06/functional-programming-moving-target.html


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-11-12  5:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.