[R] R and Scheme
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Dec 10 07:46:49 CET 2008
Johannes Huesing wrote:
> Stavros Macrakis <macrakis at alum.mit.edu> [Wed, Dec 10, 2008 at 04:59:25AM CET]:
>> So I conclude that what is really meant by "R semantics are based on Scheme
>> semantics" is "R has functions as first-class citizens and a correct
>> implementation of lexical scope, including upwards funarg".
>>
>
> One other thing reminiscient of Lisp is the infix notation (as in "+"(1, 3)),
> which the authors have sprinkled with enough syntactic sugar that the users
> needn't be bothered with. To the benefit of ubiquity, I'd think.
>
That's prefix notation, infix is "1+3" (and postfix is "1,3,+" as in old
HP calculators). But you're right that R has Lisp-like parse trees with
a thin layer of syntactic sugar:
Lisp writes function calls as (f x y) for f(x,y) and (+ 1 3) for 1+3. In
R we have
> e <- quote(f(x,y))
> e[[1]];e[[2]]; e[[3]]
f
x
y
> e <- quote(1+3)
> e[[1]];e[[2]]; e[[3]]
`+`
[1] 1
[1] 3
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list