[Top][All Lists]

[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 which is a 
tiny early Haskell dialect, better for pedagogic purposes than the current 
behemoth: Some reasons:

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 )
and unlike (E)Lisp tries hard to be a propah FPL.
The original scheme text is considered a 
programming classic by many.
I dont like it much -- shows why scheme 
though more powerful than FPLs is not properly appreciated even by its authors. 
Felleisen and Friedman I much prefer to SICP

2. APL When we were kids Lisp and APL were the two defacto FPLs.
Today Lisp has stopped being considered an FPL

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 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
3b Functional programming in python
[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.

reply via email to

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