<commit_before>#' Print a lazy stream object
#'
#' @description print a lazy stream object
#' @name lprint
#' @param x: a lazy stream
#' @param elem_max: maximum conversion size
#' @param depth_max: maximum conversion depth: drill down
#' @examples
#' # convert lazy object to R's list
#' lforce(llist(1,2,3)) # => list(1,2,3))
#' lforce(lcons(1, 2)) # => list(car = 1, cdr = 2)
NULL

#' @rdname lprint
#' @export
lprint <- function(x, elem_max = 50, depth_max = 3) {
  message("llist -> list, lcons -> list(car = , cdr = )")
  dput(lforce(x, elem_max, depth_max))
}

#' @rdname lprint
#' @export
print.lcons <- lprint

#' @rdname lprint
#' @export
lforce <- function(x, elem_max = 50, depth_max = 3) {
  # save initial value
  elem_init <- elem_max
  depth_init <- depth_max

  iter_normal <- function(x, elem_max, depth_max) {
    if (length(x) <= 1 && !is.list(x)) x
    else lapply(x, iter, elem_max = elem_init, depth_max = depth_max - 1)
  }

  iter <- function(x, elem_max, depth_max) {
    if (elem_max == 0 && !lnull(x)) {
      message("elements are over ", elem_init, "; stop converting and the rest are omitted");<commit_msg>lprint shows non-attribute by dput(..., control = NULL)<commit_after>#' Print a lazy stream object
#'
#' @description print a lazy stream object
#' @name lprint
#' @param x: a lazy stream
#' @param elem_max: maximum conversion size
#' @param depth_max: maximum conversion depth: drill down
#' @examples
#' # convert lazy object to R's list
#' lforce(llist(1,2,3)) # => list(1,2,3))
#' lforce(lcons(1, 2)) # => list(car = 1, cdr = 2)
NULL

#' @rdname lprint
#' @export
lprint <- function(x, elem_max = 50, depth_max = 3) {
  message("llist -> list, lcons -> list(car = , cdr = )")
  dput(lforce(x, elem_max, depth_max), control = NULL)
}

#' @rdname lprint
#' @export
print.lcons <- lprint

#' @rdname lprint
#' @export
lforce <- function(x, elem_max = 50, depth_max = 3) {
  # save initial value
  elem_init <- elem_max
  depth_init <- depth_max

  iter_normal <- function(x, elem_max, depth_max) {
    if (length(x) <= 1 && !is.list(x)) x
    else lapply(x, iter, elem_max = elem_init, depth_max = depth_max - 1)
  }

  iter <- function(x, elem_max, depth_max) {
    if (elem_max == 0 && !lnull(x)) {
      message("elements are over ", elem_init, "; stop converting and the rest are omitted");
{'fraction_non_alphanumeric': 0.1620926243567753, 'fraction_numerical': 0.016295025728987993, 'mean_word_length': 3.9532908704883227, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6359226', 'n_tokens_mistral': 917, 'n_tokens_neox': 831, 'n_words': 249}