Simplify API

This commit is contained in:
Joe Cheng
2012-06-29 09:34:15 -07:00
parent f3fa9883aa
commit c3268d0362
4 changed files with 43 additions and 11 deletions

View File

@@ -1,15 +1,15 @@
library(digest)
input <- Observable$new(function() {
str <- get.input('input1')
if (get.input('addnewline'))
text <- observable(function() {
str <- input$input1
if (input$addnewline)
str <- paste(str, "\n", sep='')
return(str)
})
define.output('md5_hash', function() {
digest(input$get.value(), algo='md5', serialize=F)
digest(text$get.value(), algo='md5', serialize=F)
})
define.output('sha1_hash', function() {
digest(input$get.value(), algo='sha1', serialize=F)
digest(text$get.value(), algo='sha1', serialize=F)
})

View File

@@ -1,6 +1,6 @@
data <- Observable$new(function() {
data <- observable(function() {
# Choose a distribution function
dist <- switch(get.input('dist'),
dist <- switch(input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
@@ -8,12 +8,12 @@ data <- Observable$new(function() {
rnorm)
# Generate n values from the distribution function
dist(as.integer(get.input('n')))
dist(as.integer(input$n))
})
define.plot('plot1', function() {
dist <- get.input('dist')
n <- get.input('n')
dist <- input$dist
n <- input$n
hist(data$get.value(),
main=paste('r', dist, '(', n, ')', sep=''))
@@ -25,4 +25,4 @@ define.table('table1', function() {
define.output('summary1', function() {
paste(capture.output(print(summary(data$get.value()))), collapse="\n")
})
})