help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invoking a function from a list of functions


From: Rusi
Subject: Re: Invoking a function from a list of functions
Date: Sun, 11 Nov 2018 21:39:21 -0800 (PST)
User-agent: G2/1.0

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]