update readme
This commit is contained in:
parent
cdbf155b57
commit
245584d30b
46
README.md
46
README.md
@ -28,24 +28,24 @@ formals and return types.
|
|||||||
|
|
||||||
``` r
|
``` r
|
||||||
library(ts)
|
library(ts)
|
||||||
app <- ts_list(
|
addFn <- ts_function(
|
||||||
add = ts_fun(
|
function(a = ts_numeric(1), b = ts_numeric(1)) a + b,
|
||||||
function(x, y) {
|
result = ts_numeric(1)
|
||||||
x + y
|
)
|
||||||
|
sampleFn <- ts_function(
|
||||||
|
function(x = ts_character(), n = ts_integer(1)) sample(x, n),
|
||||||
|
result = ts_character()
|
||||||
|
)
|
||||||
|
app <- ts_function(
|
||||||
|
function() {
|
||||||
|
list(
|
||||||
|
add = addFn,
|
||||||
|
sample = sampleFn
|
||||||
|
)
|
||||||
},
|
},
|
||||||
x = ts_number(1),
|
result = ts_list(
|
||||||
y = ts_number(1),
|
add = appFn,
|
||||||
# ideally this will use a generic type where x OR y can be vectors
|
sample = sampleFn
|
||||||
# and, if one is a vector, the return type will be a vector too...
|
|
||||||
result = r_numeric(1)
|
|
||||||
),
|
|
||||||
sample = ts_fun(
|
|
||||||
function(x, n) {
|
|
||||||
sample(x, n)
|
|
||||||
},
|
|
||||||
x = ts_string(),
|
|
||||||
n = ts_number(1),
|
|
||||||
result = r_character()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,10 +87,10 @@ library(ts)
|
|||||||
|
|
||||||
myfun <- ts_function(mean, x = ts_numeric(), result = ts_numeric(1))
|
myfun <- ts_function(mean, x = ts_numeric(), result = ts_numeric(1))
|
||||||
myfun(1:5)
|
myfun(1:5)
|
||||||
#> [1] 3
|
#> Error in myfun(1:5): could not find function "myfun"
|
||||||
|
|
||||||
myfun("hello world")
|
myfun("hello world")
|
||||||
#> Error: Expected a number
|
#> Error in myfun("hello world"): could not find function "myfun"
|
||||||
|
|
||||||
cat(readLines("tests/testthat/app.R"), sep = "\n")
|
cat(readLines("tests/testthat/app.R"), sep = "\n")
|
||||||
#> library(ts)
|
#> library(ts)
|
||||||
@ -107,11 +107,11 @@ cat(readLines("tests/testthat/app.R"), sep = "\n")
|
|||||||
#> )
|
#> )
|
||||||
|
|
||||||
ts_compile("tests/testthat/app.R", file = "")
|
ts_compile("tests/testthat/app.R", file = "")
|
||||||
#> import { stringArray, character, numeric } from 'rserve-ts';
|
#> import { } from 'rserve-ts';
|
||||||
#>
|
#>
|
||||||
#> const fn_first = R.ocap([z.union([z.string(), stringArray])], character(1)]);
|
#> character(0)
|
||||||
#> const fn_mean = R.ocap([z.union([z.number(), z.instanceof(Float64Array)])], numeric(1)]);
|
#> character(0)
|
||||||
#> const sample_num = R.ocap([z.instanceof(Float64Array)], numeric(1)]);
|
#> character(0)
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user