R : Copyright 2003, The R Development Core Team Version 1.7.1 (2003-06-16) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type `license()' or `licence()' for distribution details. R is a collaborative project with many contributors. Type `contributors()' for more information. Type `demo()' for some demos, `help()' for on-line help, or `help.start()' for a HTML browser interface to help. Type `q()' to quit R. > invisible(options(echo = TRUE)) > > source("fred.R") > > sum.fred <- fred(1:10, 1:5, 1:3) > sum.fred [1] 4950 > > sum <- 0 > for (i in 1:10) { + for (j in 1:5) { + for (k in 1:3) { + sum <- sum + i * j * k + } + } + } > all.equal(sum, sum.fred) [1] TRUE > > fred(1:10) [1] 55 > > sum.fred <- fred(1:10, 1:5, 1:3, func = sin) > sum.fred [1] 0.4703183 > > sum <- 0 > for (i in 1:10) { + for (j in 1:5) { + for (k in 1:3) { + sum <- sum + sin(i) * sin(j) * sin(k) + } + } + } > all.equal(sum, sum.fred) [1] TRUE > > ##### note: the following should crash > fred(func = sin) Error in sum(func(w)) : Argument "w" is missing, with no default Execution halted