R/iofunctions.R

Defines functions .initIOFunctions

.initIOFunctions <- function(){
  .fdefine('.', \() {cat(pop(), ''); .ok()})
  .fdefine('.r', \() {print(pop()); .ok()})
  .fdefine('emit', \() {cat(intToUtf8(pop())); .ok()})
  .fdefine('."', .catString)
  .fdefine('spaces', \() {cat(rep(' ', pop())); .ok()})
  .fdefine('space', \() {cat(' '); .ok()})
  .fdefine('cr', \() {cat('\n'); .ok()})
  .fdefine('u.r', \(){. <- pop(); cat(format(x=pop(), width=.)); .ok()})
}

.initIOAliases <- function(){

}


.catString <- function(){
  while(!is.null(. <- pop_op(FALSE))){
    if(grepl('\"$', .)){
      cat(substring(., 1, nchar(.)-1L), '')
      break
    }
    cat(., '')
  }
  .ok()
}

Try the froth package in your browser

Any scripts or data that you put into this service are public.

froth documentation built on June 22, 2024, 12:21 p.m.