[R] Lisp-like primitives in R

François Pinard pinard at iro.umontreal.ca
Fri Sep 7 00:10:43 CEST 2007


[Chris Elsaesser]

>> I mainly program in Common Lisp and use R for statistical analysis.  
>> While in R I miss the power and ease of use of Lisp, especially its 
>> many primitives such as find, member, cond, and (perhaps a bridge too 
>> far) loop.  Has anyone created a package that includes R analogs to 
>> a subset of Lisp functions?

[Greg Snow]

>Not all of us are familiar with lisp [...]  If you tell us what find, 
>member, cond, and loop do, or what functionality you are looking for, 
>then we will have a better chance of telling you how to do the same in 
>R.

Hi, my fRiends :-).

So far that I understand, R is built over what originally was a Scheme 
engine.  Scheme may be seen as a flavour of LISP (yet I know people that 
would strongly object seeing "Scheme" and "Lisp" in the same statement 
:-).  But it makes it rather likely that most functions you want already 
exist in R, even if under different names or syntax.

I wonder what happened, for R to hide the underlying Scheme so fully, at 
least at the level of the surface language (despite there are hints).  
Wouldn't it have been natural to have the underlying Scheme exposed as 
an extension language for R, so one might write Scheme functions just as 
well as C or FORTRAN functions?  Is the engine so far from a real Scheme 
implementation, that such an idea was never reasonable?

About the idea of Lisp-inspired library functions...  Many Lisp 
flavours, Common Lisp likely included, have a comprehensive 
(tremendous?) set of primitives and library functions.  By comparison, 
Scheme is quite moderate, and does not go much beyond the essentials, 
something which much pleases me :-).  There also are many important 
differences between Common Lisp and Scheme (like for example, global 
dynamic scoping versus textual scoping).  If R was ever to offer 
Lisp-like interfaces, RnRS (Scheme standards) might be considered, both 
for being simpler, and more in the spirit of what R already is.

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the R-help mailing list