Article View: comp.lang.misc
Article #6635Re: The Fundamental Concept of Programming language X
From: Barry Margolin
Date: Fri, 12 Jan 1990 05:39
Date: Fri, 12 Jan 1990 05:39
40 lines
1883 bytes
1883 bytes
In article <666@s5.Morgan.COM> amull@Morgan.COM (Andrew P. Mullhaupt) writes:
>In article <1532@castle.ed.ac.uk>, nick@lfcs.ed.ac.uk (Nick Rothwell) writes:
>> Why are "operators" different to functions?
>They can have functions as arguments.
...
>Functions, therefore, are not 'first class data' since the functions
>which operate on them are not functions. (This is a lot like Lisp).
Lisp doesn't have the distinction between functions and operators. In
Lisp, functions can take functions as arguments and return them as values.
For instance, in Common Lisp one can write:
(defun complement (function)
#'(lambda (&rest args)
(not (apply function args))))
(complement <function>) returns a function that returns true when the
original function returns false, and vice versa (this function will be part
of ANSI Common Lisp). One could then write:
(setf (symbol-function 'nequal) (complement #'equal))
or
(funcall (complement #'member) 'foo *some-list*)
And here's a simple definition of APL's / operator:
(defun compress (function)
#'(lambda (&rest args)
(reduce function args)))
;;; If Lisp didn't already have an n-argument +, one could write:
(defun sum (&rest values)
(apply (compress #'+) values))
--
Barry Margolin, Thinking Machines Corp.
barmar@think.com
{uunet,harvard}!think!barmar
Technical Details
Message-ID:
<32824@news.Think.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker!think!barmarReferences:
<1470@mdbs.UUCP> <1782@aipna.ed.ac.uk> <2886@water.waterloo.edu> <1532@castle.ed.ac.uk> <666@s5.Morgan.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker!think!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.misc Subject: Re: The Fundamental Concept of Programming language X Keywords: programming languages, abstractions Message-ID: <32824@news.Think.COM> Date: 12 Jan 90 05:39:38 GMT References: <1470@mdbs.UUCP> <1782@aipna.ed.ac.uk> <2886@water.waterloo.edu> <1532@castle.ed.ac.uk> <666@s5.Morgan.COM> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 40