Hacker News new | ask | show | jobs
by fxj 2268 days ago
The R engine began life as a very simple Lisp interpreter. There is also an R package which gives the Lisp-style representation of an R expression. You can even use it as a R to Lisp Compiler.

https://stat.ethz.ch/R-manual/R-patched/library/codetools/ht...

http://dan.corlan.net/R_to_common_lisp_translator/

1 comments

Thanks. I wasn't aware of showTree.

Most R users don't realize everything in R can be written as a function, due to its Scheme roots. Example:

if (3 > 2) { print("hello") }

can be rewritten with backticks on the if:

`if`(3 > 2, print("hello"))

If the first argument is false, you need a third argument

`if`(3 < 2, print("hello"), print("go away"))

Essentially, the backticks replace some parens you'd use in Scheme, and then you can add some alternative syntactic sugar to write in Algol style.

Yup.

If you look in the source for R (in C), you will note that all of the data structure names end with Sexp.