## Example of calling rnorm in froth
## rnorm expects 3 arguments: rnorm(n, mean, sd)
froth.RDefine(name='R_rnorm', fun=rnorm, nargs=3L)
## Now we can call rnorm from froth using the 'R_rnorm' word.
## Note that the arguments are expected on the stack
## such that the top of the stack is `sd`,
## the second is `mean`, and the third is `n`.
## n
froth.RPush(5)
## mean
froth.RPush(0.0)
## sd
froth.RPush(1.0)
## running the function
## note this will push the results back onto the stack
froth.parse("R_rnorm")
## we can get the result with froth.RPop
froth.RPop(5L)
## As a oneliner: (doesn't return the values)
froth.parse("5 0 1 R_rnorm .s")
Run the code above in your browser using DataLab