From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Rusi Newsgroups: gmane.emacs.help Subject: Re: Invoking a function from a list of functions Date: Sun, 11 Nov 2018 21:39:21 -0800 (PST) Message-ID: <67c4a534-d41c-4736-8839-c2dbbdf7f9c2@googlegroups.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1542001111 5783 195.159.176.226 (12 Nov 2018 05:38:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Nov 2018 05:38:31 +0000 (UTC) Injection-Date: Mon, 12 Nov 2018 05:39:21 +0000 User-Agent: G2/1.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 12 06:38:27 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gM4vY-0001MW-La for geh-help-gnu-emacs@m.gmane.org; Mon, 12 Nov 2018 06:38:24 +0100 Original-Received: from localhost ([::1]:44884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gM4xe-0004NP-NQ for geh-help-gnu-emacs@m.gmane.org; Mon, 12 Nov 2018 00:40:34 -0500 X-Received: by 2002:a5e:da07:: with SMTP id x7-v6mr1522738ioj.35.1542001161789; Sun, 11 Nov 2018 21:39:21 -0800 (PST) X-Received: by 2002:a37:1251:: with SMTP id c78mr131258qkh.1.1542001161484; Sun, 11 Nov 2018 21:39:21 -0800 (PST) Original-Path: usenet.stanford.edu!g188-v6no2994385itg.0!news-out.google.com!n199-v6ni4979itn.0!nntp.google.com!g188-v6no2994382itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=59.93.200.249; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 59.93.200.249 Original-Xref: usenet.stanford.edu gnu.emacs.help:224522 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118651 Archived-At: Stefan and Yuri have pointed you to the search terms =E2=80=9Chigher order= =E2=80=9D and =E2=80=9Cfirst class=E2=80=9D 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 t= ilts towards Haskell: which is somewhat like using a missile to kill a fly. Me: After having tried many options for teaching programming, Ive personall= y returned to gofer http://blog.languager.org/2014/09/pugofer.html which is= a tiny early Haskell dialect, better for pedagogic purposes than the curre= nt 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 reasona= ble 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-sic= p.html shows why scheme though more powerful than FPLs is not properly appr= eciated 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 = =E2=80=94 (funcall (nth 1 funcs)) =E2=80=94 I assume you are sensing that = short expressions can be amazingly powerful and want to learn how to do mor= e of that. Look at https://aplwiki.com/FinnAplIdiomLibrary for more such AP= L 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 mo= st optimal setting. People self learning or with less time etc this may be = unpleasant/formidable. And since you seem familiar with python there are a= lso 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-Pytho= n-Programming-Steven-Lott/dp/1784396990 [Disclaimer I have not delved into either of these so you spend your time a= t your risk] Summary: If you wanted to learn Portuguese you could do it anywhere =E2=80= =94 NY, London Delhi Tokyo. However staying in Lisbon or Rio de Janeiro wi= ll give you more success (presumably!). Python copied its list comprehensio= ns 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 =E2=80=94 "comprehensions are hard; first learn to write for-loo= ps..." etc. So paradoxically the best way to do comprehensions in python is by learning= them out of python=E2=80=A6 Likewise FP in (E)Lisp tl;dr: =E2=80=98(funcall (nth 1 funcs)) =E2=80=99 is an example of FP style= . Lisp/python can be used (for the most part) as an FPL. The cultural quest= ions are the bigger impediment than the technical/factual ones FP can be language independent=E2=80=A6 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