
50 R Programming for Bioinformatics
> even = function(i) i %% 2 == 0
> testEven = function(i) if (even(i) ) i else stop("not even")
> vals = NULL
> withCallingHandlers({
+ for (i in seq_len(10)) {
+ val = withRestarts(testEven(i),
+ skipError=function() return(NULL))
+ if (!is.null(val))
+ vals = c(vals, val)
+ }},
+ error=function(e) invokeRestart("skipError"))
> vals
[1] 2 4 6 8 10
2.12 Evaluation
Computer languages provide a level of abstraction that allows programmers,
and users, the ability to express certain ideas symbolically. In many cases
the symbolic statements constitute a program, or a function that may be
evaluated many times, with potentially