Recursive evaluation of a function (func
) on each attribute (vector) in a sub_criteria
.
attr_eval(x, func = length, simplify = TRUE)
[function]
If TRUE
(default), coerce to a vector.
vector
; list
x <- sub_criteria(rep(1, 5), rep(5 * 10, 5))
attr_eval(x)
#> [1] 5 5
attr_eval(x, func = max)
#> [1] 1 50
attr_eval(x, func = max, simplify = FALSE)
#> [[1]]
#> [1] 1
#>
#> [[2]]
#> [1] 50
#>
attr_eval(sub_criteria(x, x), func = max, simplify = FALSE)
#> [[1]]
#> [[1]][[1]]
#> [1] 1
#>
#> [[1]][[2]]
#> [1] 50
#>
#>
#> [[2]]
#> [[2]][[1]]
#> [1] 1
#>
#> [[2]][[2]]
#> [1] 50
#>
#>