R/l_getNDimStates.R

Defines functions l_getNDimStates.l_compound l_getNDimStates.loon l_getNDimStates

l_getNDimStates <- function(widget) {
  UseMethod("l_getNDimStates", widget)
}

l_getNDimStates.loon <- function(widget) {
  statesNames <- loon::l_nDimStateNames(widget)
  states <- stats::setNames(
    lapply(statesNames,
           function(s) {
             if(length(widget[s]) == 0) return(NULL)
             widget[s]
           }),
    statesNames)
  # remove NULL
  remove_null(states, as_list = FALSE)
}

l_getNDimStates.l_compound <- function(widget) {
  lapply(widget, function(x) l_getNDimStates(x))
}

Try the loon.tourr package in your browser

Any scripts or data that you put into this service are public.

loon.tourr documentation built on Oct. 27, 2021, 5:09 p.m.