Skip to contents

All values are stored in a one-dimensional named list. Dots in names define virtual groups (the "implied" nesting) of the vector.

Usage

implicit_nested_list(x = list())

explicit_nested_list(flat)

Arguments

x

(list)
Named values to store. Named elements are recursively flattened.

flat

(implicit_nested_list(1))
1D list to transform

Value

(implicit_nested_list)
A flat list with virtual nested access.

Details

Named vectors or lists are recursively flattened on construction and assignment to keep the underlying structure fully one-dimensional. Reading a group returns an ordinary named vector if every immediate child is a scalar of the same atomic type; otherwise it returns an ordinary list.

Simplification is strict: integer + double and numeric + character stay lists.

Examples

  x <- implicit_nested_list(list(compartments = c("E" = 2L, "I" = 3L)))
  x$compartments[["I"]] <- 4L
  stopifnot(identical(x[["compartments.I"]], 4L))