making-a-lisp implementation of R

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

making-a-lisp implementation of R

Jérémie Juste

Hello,

I was trying to make my R implementation of making-a-lisp
https://github.com/kanaka/mal/tree/master/

And to my surprise I got stuck in the starting blocks. There is already
a mal implementation of R here
https://github.com/kanaka/mal/tree/master/r but it uses rdyncall package
which is not on CRAN anymore and I thought it would be fun to try my
skills here

The following code is step0_repl.r but it does pass the test. Do you
have any idea why?


READ <- function(arg){
    return(arg)
    }


EVAL <- function(arg){
    return(arg)
}

PRINT <- function(arg){
    return(arg)
}

REP <- function(arg){
    PRINT(EVAL(READ(arg)))
}





tryCatch({
    while(TRUE){
        cat("user> ")
        input <- tryCatch(readLines(n=1),error=function(e) character(0))
        if (identical(input,character(0))) {            
            stop
        } else{
            if(input==""){next} else
                                  cat(REP(input),"\n",sep="")
        }
    }
},error=function(err){
    cat( err$message,"\ninput: ",input,"\n", sep="")
})




Best regards,

Jeremie

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.