It's often heard that the S language is a functional language.But What's the exact meaning of this termology in the context of S language? 2005-10-18 ------ Deparment of Sociology Fudan University Blog:http://sociology.yculblog.com
The meaning of functional language
4 messages · ronggui, Hadley Wickham, Patrick Burns +1 more
It's often heard that the S language is a functional language.But What's the exact meaning of this termology in the context of S language?
For general computer science definitions, wikipedia is normally useful: http://en.wikipedia.org/wiki/Functional_language Hadley
ronggui wrote:
It's often heard that the S language is a functional language.But What's the exact meaning of this termology in the context of S language?
Here's the idea. If you have:
x <- 1:10
f <- function(y) { x <- sin(y / 2); x + y}
f(-3:3)
then the 'x' inside 'f' does not wipe out your top-level 'x'
when 'f' is called.
Operationally it means that objects are only changed via
the assignment operator. (This is not strictly true, but other
vehicles, such as '<<-', are generally considered bad style.)
The reason for wanting this behavior is so that you don't need
to worry about objects getting invisibly changed while you
are analyzing some data, or whatever it is that you are doing.
That is, the language was designed to be human efficient, while
sacrificing some machine efficiency.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
'functional' languages derive from LISP and the lamda-calculus. These are standard topics in CS computer language courses. You can look them up in Wikipedia, or Google for other sources. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box
-----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Patrick Burns Sent: Tuesday, October 18, 2005 2:40 PM To: ronggui Cc: r-help at stat.math.ethz.ch Subject: Re: [R] The meaning of functional language ronggui wrote:
It's often heard that the S language is a functional
language.But What's the exact meaning of this termology in the context of S language?
Here's the idea. If you have:
x <- 1:10
f <- function(y) { x <- sin(y / 2); x + y}
f(-3:3)
then the 'x' inside 'f' does not wipe out your top-level 'x'
when 'f' is called.
Operationally it means that objects are only changed via
the assignment operator. (This is not strictly true, but other
vehicles, such as '<<-', are generally considered bad style.)
The reason for wanting this behavior is so that you don't need
to worry about objects getting invisibly changed while you
are analyzing some data, or whatever it is that you are doing.
That is, the language was designed to be human efficient, while
sacrificing some machine efficiency.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")