all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rusi <rustompmody@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Invoking a function from a list of functions
Date: Sun, 11 Nov 2018 21:39:21 -0800 (PST)	[thread overview]
Message-ID: <67c4a534-d41c-4736-8839-c2dbbdf7f9c2@googlegroups.com> (raw)
In-Reply-To: <mailman.3677.1541718983.1284.help-gnu-emacs@gnu.org>

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	other threads:[~2018-11-12  5:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3677.1541718983.1284.help-gnu-emacs@gnu.org>
2018-11-12  5:39 ` Rusi [this message]
2018-11-12 15:19   ` [OFFTOPIC] Re: Invoking a function from a list of functions Stefan Monnier
     [not found]   ` <mailman.3921.1542036006.1284.help-gnu-emacs@gnu.org>
2018-11-16  2:48     ` Rusi
2018-11-16 16:40       ` James K. Lowden
2018-11-17 15:59         ` Rusi
2018-11-19 22:23           ` James K. Lowden
2018-11-19 23:11             ` Stefan Monnier
2018-11-20  6:15               ` Amin Bandali
2018-11-21 15:05                 ` Stefan Monnier
2018-11-23  3:41                   ` Amin Bandali
     [not found]               ` <mailman.4291.1542694542.1284.help-gnu-emacs@gnu.org>
2018-11-28 14:14                 ` Rusi
2018-12-11 18:48                   ` Amin Bandali
     [not found]             ` <mailman.4280.1542669123.1284.help-gnu-emacs@gnu.org>
2018-11-28 14:10               ` Rusi
2018-11-28 16:31                 ` Eli Zaretskii
2018-11-28 18:15                   ` Yuri Khan
2018-11-28 18:57                     ` Eli Zaretskii
2018-11-28 19:08                       ` Yuri Khan
     [not found]                       ` <mailman.4820.1543432126.1284.help-gnu-emacs@gnu.org>
2018-11-29  5:37                         ` Rusi
2018-11-16 16:40       ` James K. Lowden
2018-11-16 17:15         ` Drew Adams
2018-11-08 23:01 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

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=67c4a534-d41c-4736-8839-c2dbbdf7f9c2@googlegroups.com \
    --to=rustompmody@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.