Given two lists (pl_base and pl_default), the lists should be merged into a result list (l_result) such that the result contains all entries of pl_base and for the entries whose names are in pl_default, but are not in pl_base, the entries of pl_default is included in l_result. This leads to a list (l_result) which has the same names as pl_default, but for those names which are also in pl_base, the values from pl_base overwrite the values of pl_default.

merge_list_to_default(pl_base, pl_default)

Arguments

pl_base

list of base entries

pl_default

list with default entries

Value

l_result list with merged entries of pl_base and pl_default

Details

This merging procedure is used in replacement of placeholders in templates where only parts of the placeholders are replaced with specified values and the rest is replaced with assumed default values.

Examples

if (FALSE) {
n <- 9
l2 <- lapply(1:n, function(x) x)
names(l2) <- LETTERS[1:9]
merge_list_to_default(pl_base = list(A = 10L, B = 20L), pl_default = l2)
}