From a87807aea1c2d620ff366ee5087ae97debf05542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Thu, 3 Sep 2026 14:23:41 +0200 Subject: [PATCH] chore: more `\(x)` --- R/aaa-cliques.R | 8 ++++---- R/aaa-community.R | 4 ++-- R/aaa-cycles.R | 4 ++-- R/aaa-games.R | 2 +- R/aaa-generators.R | 2 +- R/aaa-graphlets.R | 2 +- R/aaa-isomorphism.R | 10 +++++----- R/aaa-layout.R | 4 ++-- R/aaa-motifs.R | 4 ++-- R/aaa-operators.R | 6 +++--- R/aaa-structural.R | 4 ++-- R/aaa-visitors.R | 12 ++++++------ R/attributes.R | 4 ++-- R/centrality.R | 4 ++-- R/cliques.R | 2 +- R/community.R | 2 +- R/console.R | 10 +++++----- R/conversion.R | 8 ++++---- R/epi.R | 12 ++++++------ R/glet.R | 2 +- R/has.R | 8 ++++---- R/hrg.R | 4 ++-- R/indexing.R | 2 +- R/iterators.R | 8 ++++---- R/layout.R | 8 ++++---- R/make.R | 6 +++--- R/operators.R | 18 +++++++++--------- R/par.R | 2 +- R/plot.R | 14 +++++++------- R/plot.common.R | 4 ++-- R/plot.shapes.R | 18 +++++++++--------- R/print.R | 20 ++++++++++---------- R/scan.R | 2 +- R/structural-properties.R | 6 +++--- R/tkplot.R | 36 ++++++++++++++++++------------------ R/topology.R | 8 ++++---- R/utils-s3.R | 8 ++++---- tools/stimulus/types-RR.yaml | 14 +++++++------- 38 files changed, 146 insertions(+), 146 deletions(-) diff --git a/R/aaa-cliques.R b/R/aaa-cliques.R index 83f6472fdf4..d97dddcb071 100644 --- a/R/aaa-cliques.R +++ b/R/aaa-cliques.R @@ -66,8 +66,8 @@ cliques_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { @@ -192,8 +192,8 @@ maximal_cliques_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/aaa-community.R b/R/aaa-community.R index a67057ab763..175566422d1 100644 --- a/R/aaa-community.R +++ b/R/aaa-community.R @@ -319,8 +319,8 @@ community_leading_eigenvector_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/aaa-cycles.R b/R/aaa-cycles.R index f7671c6bde0..bdead6d90bd 100644 --- a/R/aaa-cycles.R +++ b/R/aaa-cycles.R @@ -329,8 +329,8 @@ simple_cycles_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/aaa-games.R b/R/aaa-games.R index ecc4ac3d776..ce98d1a7a89 100644 --- a/R/aaa-games.R +++ b/R/aaa-games.R @@ -484,7 +484,7 @@ hsbm_list_game_impl <- function( if (!is.list(Clist)) { cli::cli_abort("{.arg Clist} must be a list of matrices") } - Clist <- lapply(Clist, function(m) { + Clist <- lapply(Clist, \(m) { if (!is.matrix(m)) { cli::cli_abort("{.arg Clist} must be a list of matrices") } diff --git a/R/aaa-generators.R b/R/aaa-generators.R index 09bf075a9ad..58e353d88a6 100644 --- a/R/aaa-generators.R +++ b/R/aaa-generators.R @@ -40,7 +40,7 @@ adjlist_impl <- function( duplicate = TRUE ) { # Argument checks - adjlist <- lapply(adjlist, function(x) as.numeric(x) - 1) + adjlist <- lapply(adjlist, \(x) as.numeric(x) - 1) mode <- switch_igraph_arg( mode, "out" = 1L, diff --git a/R/aaa-graphlets.R b/R/aaa-graphlets.R index e9604885b0c..949f0e223e2 100644 --- a/R/aaa-graphlets.R +++ b/R/aaa-graphlets.R @@ -96,7 +96,7 @@ graphlets_project_impl <- function( R_igraph_graphlets_project, graph, weights, - if (!is.null(cliques)) lapply(cliques, function(.x) .x - 1), + if (!is.null(cliques)) lapply(cliques, \(.x) .x - 1), Muc, startMu, niter diff --git a/R/aaa-isomorphism.R b/R/aaa-isomorphism.R index 343419a9d95..81104c6a3f7 100644 --- a/R/aaa-isomorphism.R +++ b/R/aaa-isomorphism.R @@ -362,7 +362,7 @@ subisomorphic_lad_impl <- function( R_igraph_subisomorphic_lad, pattern, target, - if (!is.null(domains)) lapply(domains, function(.x) .x - 1), + if (!is.null(domains)) lapply(domains, \(.x) .x - 1), induced, time_limit ) @@ -572,8 +572,8 @@ get_isomorphisms_vf2_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { @@ -730,8 +730,8 @@ get_subisomorphisms_vf2_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/aaa-layout.R b/R/aaa-layout.R index e076ebc7cce..62bfea68f91 100644 --- a/R/aaa-layout.R +++ b/R/aaa-layout.R @@ -304,7 +304,7 @@ layout_merge_dla_impl <- function( if (!is.list(graphs)) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } - graphs <- lapply(graphs, function(g) { + graphs <- lapply(graphs, \(g) { if (!inherits(g, "igraph")) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } @@ -313,7 +313,7 @@ layout_merge_dla_impl <- function( if (!is.list(coords)) { cli::cli_abort("{.arg coords} must be a list of matrices") } - coords <- lapply(coords, function(m) { + coords <- lapply(coords, \(m) { if (!is.matrix(m)) { cli::cli_abort("{.arg coords} must be a list of matrices") } diff --git a/R/aaa-motifs.R b/R/aaa-motifs.R index 9f6ce32afa7..bcf35cbccf2 100644 --- a/R/aaa-motifs.R +++ b/R/aaa-motifs.R @@ -84,8 +84,8 @@ motifs_randesu_callback_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/aaa-operators.R b/R/aaa-operators.R index 1c81fcd5262..3b2a5d70f25 100644 --- a/R/aaa-operators.R +++ b/R/aaa-operators.R @@ -407,7 +407,7 @@ disjoint_union_many_impl <- function( if (!is.list(graphs)) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } - graphs <- lapply(graphs, function(g) { + graphs <- lapply(graphs, \(g) { if (!inherits(g, "igraph")) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } @@ -450,7 +450,7 @@ intersection_many_impl <- function( if (!is.list(graphs)) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } - graphs <- lapply(graphs, function(g) { + graphs <- lapply(graphs, \(g) { if (!inherits(g, "igraph")) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } @@ -512,7 +512,7 @@ union_many_impl <- function( if (!is.list(graphs)) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } - graphs <- lapply(graphs, function(g) { + graphs <- lapply(graphs, \(g) { if (!inherits(g, "igraph")) { cli::cli_abort("{.arg graphs} must be a list of igraph objects") } diff --git a/R/aaa-structural.R b/R/aaa-structural.R index de9543e847b..75324a8053b 100644 --- a/R/aaa-structural.R +++ b/R/aaa-structural.R @@ -1543,7 +1543,7 @@ local_scan_neighborhood_ecount_impl <- function( R_igraph_local_scan_neighborhood_ecount, graph, weights, - if (!is.null(neighborhoods)) lapply(neighborhoods, function(.x) .x - 1) + if (!is.null(neighborhoods)) lapply(neighborhoods, \(.x) .x - 1) ) res @@ -1577,7 +1577,7 @@ local_scan_subset_ecount_impl <- function( R_igraph_local_scan_subset_ecount, graph, weights, - if (!is.null(subsets)) lapply(subsets, function(.x) .x - 1) + if (!is.null(subsets)) lapply(subsets, \(.x) .x - 1) ) res diff --git a/R/aaa-visitors.R b/R/aaa-visitors.R index dbf822202c3..18b9724f3bb 100644 --- a/R/aaa-visitors.R +++ b/R/aaa-visitors.R @@ -52,8 +52,8 @@ bfs_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { @@ -156,8 +156,8 @@ dfs_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { @@ -178,8 +178,8 @@ dfs_closure_impl <- function( rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { diff --git a/R/attributes.R b/R/attributes.R index 0d2d0a19677..28c5a31921a 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -1319,7 +1319,7 @@ igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) { } comb <- as.list(comb) if ( - !all(sapply(comb, function(x) { + !all(sapply(comb, \(x) { is.function(x) || (is.character(x) && length(x) == 1) })) ) { @@ -1356,7 +1356,7 @@ igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) { known_names <- c(known_names, "rename") known_codes <- c(known_codes, NA_integer_) } - comb <- lapply(comb, function(x) { + comb <- lapply(comb, \(x) { if (!is.character(x)) { x } else { diff --git a/R/centrality.R b/R/centrality.R index 39ee45778a7..01ac5294f61 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -1136,9 +1136,9 @@ arpack <- function( res$vectors <- rew$vectors res$values <- rew$values - res$values <- apply(res$values, 1, function(x) x[1] + x[2] * 1i) + res$values <- apply(res$values, 1, \(x) x[1] + x[2] * 1i) dim(res$vectors) <- c(nrow(res$vectors) * 2, ncol(res$vectors) / 2) - res$vectors <- apply(res$vectors, 2, function(x) { + res$vectors <- apply(res$vectors, 2, \(x) { l <- length(x) / 2 x[1:l] + x[(l + 1):length(x)] * 1i }) diff --git a/R/cliques.R b/R/cliques.R index 29fefbe4a65..5ec0b19808e 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -355,7 +355,7 @@ max_cliques <- function( as.numeric(min %||% 0), as.numeric(max %||% 0) ) - res <- lapply(res, function(x) x + 1) + res <- lapply(res, \(x) x + 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) diff --git a/R/community.R b/R/community.R index 5ddf79674e4..fea03e87bf0 100644 --- a/R/community.R +++ b/R/community.R @@ -3583,7 +3583,7 @@ groups.default <- function(x) { if (is.null(vids)) { vids <- seq_along(x$membership) } - tapply(vids, x$membership, simplify = FALSE, function(x) x) + tapply(vids, x$membership, simplify = FALSE, \(x) x) } #' @method groups communities diff --git a/R/console.R b/R/console.R index 6c8f6bb208e..a9fde8beddc 100644 --- a/R/console.R +++ b/R/console.R @@ -201,11 +201,11 @@ console <- function() { scr <- tcltk::tkscrollbar( console, repeatinterval = 5, - command = function(...) tcltk::tkyview(txt, ...) + command = \(...) tcltk::tkyview(txt, ...) ) txt <- tcltk::tktext( console, - yscrollcommand = function(...) tcltk::tkset(scr, ...), + yscrollcommand = \(...) tcltk::tkset(scr, ...), width = 60, height = 7, font = fn @@ -213,12 +213,12 @@ console <- function() { tcltk::tkconfigure(txt, state = "disabled") pbar <- .igraph.progress.tkconsole.pbar(console) - bclear <- tcltk::tkbutton(lfr, text = "Clear", command = function() { + bclear <- tcltk::tkbutton(lfr, text = "Clear", command = \() { tcltk::tkconfigure(txt, state = "normal") tcltk::tkdelete(txt, "0.0", "end") tcltk::tkconfigure(txt, state = "disabled") }) - bclose <- tcltk::tkbutton(lfr, text = "Close", command = function() { + bclose <- tcltk::tkbutton(lfr, text = "Close", command = \() { if (!is.na(oldverb) && igraph_opt("verbose") == "tkconsole") { igraph_options(verbose = oldverb) } @@ -243,7 +243,7 @@ console <- function() { tcltk::tkpack(scr, side = "right", fill = "y", expand = 0) tcltk::tkpack(txt, side = "left", fill = "both", expand = 1) - tcltk::tkbind(console, "", function() { + tcltk::tkbind(console, "", \() { if (!is.na(oldverb) && igraph_opt("verbose") == "tkconsole") { igraph_options(verbose = oldverb) } diff --git a/R/conversion.R b/R/conversion.R index 61791722a72..ebc4303cca0 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -993,7 +993,7 @@ as_adj_edge_list <- function( on.exit(.Call(Rx_igraph_finalizer)) res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) - res <- lapply(res, function(.x) E(graph)[.x + 1]) + res <- lapply(res, \(.x) E(graph)[.x + 1]) if (is_named(graph)) { names(res) <- V(graph)$name } @@ -1100,7 +1100,7 @@ graph_from_graphnel <- function( al <- lapply(graph::edgeL(graphNEL), "[[", "edges") if (graph::edgemode(graphNEL) == "undirected") { - al <- mapply(SIMPLIFY = FALSE, seq_along(al), al, FUN = function(n, l) { + al <- mapply(SIMPLIFY = FALSE, seq_along(al), al, FUN = \(n, l) { c(l, rep(n, sum(l == n))) }) } @@ -1210,7 +1210,7 @@ as_graphnel <- function(graph) { } } else { al <- as_adj_list(graph, mode = "out", loops = "once") - al <- lapply(al, function(x) list(edges = as.vector(x))) + al <- lapply(al, \(x) list(edges = as.vector(x))) } names(al) <- name @@ -1248,7 +1248,7 @@ as_graphnel <- function(graph) { for (n in e.n) { graph::edgeDataDefaults(res, attr = n) <- NA res@edgeData@data[el] <- mapply( - function(x, y) { + \(x, y) { xx <- c(x, y) names(xx)[length(xx)] <- n xx diff --git a/R/epi.R b/R/epi.R index ad2871cbdec..4d4cb8d1d8d 100644 --- a/R/epi.R +++ b/R/epi.R @@ -110,12 +110,12 @@ quantile.sir <- function(x, comp = c("NI", "NS", "NR"), prob, ...) { sir <- x comp <- toupper(igraph_match_arg(comp)) times <- unlist(sapply(sir, "[[", "times")) - big.N <- unlist(sapply(sir, function(x) { + big.N <- unlist(sapply(sir, \(x) { x[[comp]] })) time.bin <- cut(times, time_bins(sir, middle = FALSE), include.lowest = TRUE) - res <- lapply(prob, function(pp) { - tapply(big.N, time.bin, function(x) { + res <- lapply(prob, \(pp) { + tapply(big.N, time.bin, \(x) { quantile(x, prob = pp) }) }) @@ -215,8 +215,8 @@ plot.sir <- function( } quantile_color <- rep(quantile_color, length.out = length(quantiles)) - xlim <- xlim %||% c(0, max(sapply(sir, function(x) max(x$times)))) - ylim <- ylim %||% c(0, max(sapply(sir, function(x) max(x[[comp]])))) + xlim <- xlim %||% c(0, max(sapply(sir, \(x) max(x$times)))) + ylim <- ylim %||% c(0, max(sapply(sir, \(x) max(x[[comp]])))) ## Generate the plot, first with individual curves, and then ## adding median and quantile curves. @@ -244,7 +244,7 @@ plot.sir <- function( ylab = ylab, ... ) - lapply(seq_along(sir), function(i) { + lapply(seq_along(sir), \(i) { lines(sir[[i]]$times, sir[[i]][[comp]], col = color[1]) }) diff --git a/R/glet.R b/R/glet.R index be7843b6c28..7eb43a96be5 100644 --- a/R/glet.R +++ b/R/glet.R @@ -264,7 +264,7 @@ graphlet_proj <- function( ################# ## Example code -function() { +\() { library(igraph) fitandplot <- function(g, gl) { diff --git a/R/has.R b/R/has.R index aff7284915a..196e6693120 100644 --- a/R/has.R +++ b/R/has.R @@ -5,20 +5,20 @@ make_closure <- function(fun, ...) { fun } -has_glpk <- make_closure(glpk = NULL, function() { +has_glpk <- make_closure(glpk = NULL, \() { if (is.null(glpk)) { glpk <<- tryCatch( { cluster_optimal(make_ring(10)) TRUE }, - error = function(e) FALSE + error = \(e) FALSE ) } glpk }) -has_graphml <- make_closure(graphml = NULL, function() { +has_graphml <- make_closure(graphml = NULL, \() { if (is.null(graphml)) { graphml <<- tryCatch( { @@ -28,7 +28,7 @@ has_graphml <- make_closure(graphml = NULL, function() { ) TRUE }, - error = function(e) FALSE + error = \(e) FALSE ) } graphml diff --git a/R/hrg.R b/R/hrg.R index 5d9b5ae0eaa..cde45b9d081 100644 --- a/R/hrg.R +++ b/R/hrg.R @@ -1149,7 +1149,7 @@ print2.igraphHRG <- function(x, ...) { p <- format(x$prob, digits = 1) pw <- 4 + max(nchar(p)) nn <- if (is.null(x$names)) seq_len(length(x$left) + 1) else x$names - op <- sapply(seq_along(x$left), function(i) { + op <- sapply(seq_along(x$left), \(i) { lc <- if (x$left[i] < 0) { paste(sep = "", "g", -x$left[i]) } else { @@ -1203,7 +1203,7 @@ print.igraphHRGConsensus <- function(x, ...) { ch <- tapply(id, x$parents, c)[-1] # first is zero bw <- nchar(as.character(length(x$weights))) vw <- max(nchar(id)) - op <- sapply(seq_along(x$weights), function(i) { + op <- sapply(seq_along(x$weights), \(i) { mych <- format(ch[[i]], width = vw) if (length(ch[[i]]) * (vw + 1) + bw + 4 > getOption("width")) { mych <- gsub(" ", "x", mych, fixed = TRUE) diff --git a/R/indexing.R b/R/indexing.R index 1f61e246621..6710d4257be 100644 --- a/R/indexing.R +++ b/R/indexing.R @@ -421,7 +421,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) { i <- as_igraph_vs(x, i) j <- as_igraph_vs(x, j) ee <- incident_edges(x, i, mode = if (directed) "out" else "all") - lapply(seq_along(i), function(yy) { + lapply(seq_along(i), \(yy) { from <- i[yy] el <- ends(x, ee[[yy]], names = FALSE) other <- ifelse(el[, 1] == from, el[, 2], el[, 1]) diff --git a/R/iterators.R b/R/iterators.R index 9db0178ad54..fc9fb8717d8 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -806,7 +806,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { res <- lapply(args, rlang::eval_tidy, data = data_mask) - res <- lapply(res, function(ii) { + res <- lapply(res, \(ii) { if (is.null(ii)) { return(NULL) } @@ -1156,7 +1156,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { res <- lapply(args, rlang::eval_tidy, data = data_mask) - res <- lapply(res, function(ii) { + res <- lapply(res, \(ii) { if (is.null(ii)) { return(NULL) } @@ -1921,7 +1921,7 @@ parse_op_args <- function(..., what, is_fun, as_fun, check_graph = TRUE) { drop_null() addresses <- graphs |> - sapply(function(x) x %&&% address(x)) |> + sapply(\(x) x %&&% address(x)) |> unique() if (check_graph && length(addresses) >= 2) { @@ -1965,7 +1965,7 @@ create_op_result <- function(parsed, result, class, args) { ## c() drops names for zero length vectors. Why??? if ( !length(result) && - any(sapply(args, function(x) !is.null(names(x)))) + any(sapply(args, \(x) !is.null(names(x)))) ) { names(result) <- character() } diff --git a/R/layout.R b/R/layout.R index 35f96239eb4..f2f3acf0854 100644 --- a/R/layout.R +++ b/R/layout.R @@ -440,7 +440,7 @@ layout_ <- function(graph, layout, ...) { names(modifiers) <- ids # Separate modifiers by type - is_pre <- vapply(modifiers, function(m) isTRUE(m$type == "pre"), logical(1)) + is_pre <- vapply(modifiers, \(m) isTRUE(m$type == "pre"), logical(1)) pre_modifiers <- modifiers[is_pre] post_modifiers <- modifiers[!is_pre] @@ -597,10 +597,10 @@ component_wise <- function(merge_method = "dla") { id = "component_wise", type = "pre", args = args, - apply = function(graph, layout, modifier_args) { + apply = \(graph, layout, modifier_args) { graph$id <- seq(vcount(graph)) comps <- decompose(graph) - coords <- lapply(comps, function(comp) { + coords <- lapply(comps, \(comp) { do_call(layout$fun, list(graph = comp), layout$args) }) all_coords <- merge_coords( @@ -662,7 +662,7 @@ normalize <- function( id = "normalize", type = "post", args = args, - apply = function(graph, layout, modifier_args) { + apply = \(graph, layout, modifier_args) { do_call( norm_coords, list(layout), diff --git a/R/make.R b/R/make.R index 1c930253056..b9a2e4f5678 100644 --- a/R/make.R +++ b/R/make.R @@ -1860,14 +1860,14 @@ graph_from_literal_i <- function(mf) { } } - ret <- lapply(mf, function(x) unlist(f(x))) + ret <- lapply(mf, \(x) unlist(f(x))) - v <- unique(unlist(lapply(ret, function(x) { + v <- unique(unlist(lapply(ret, \(x) { x[names(x) == "sym"] }))) ## Merge symbols for ":" - ret <- lapply(ret, function(x) { + ret <- lapply(ret, \(x) { res <- list() for (i in seq(along.with = x)) { if (x[i] == ":" && names(x)[i] == "op") { diff --git a/R/operators.R b/R/operators.R index ef2084d8212..35503a35d9f 100644 --- a/R/operators.R +++ b/R/operators.R @@ -182,7 +182,7 @@ combine.attrs <- function( attr <- list() for (name in an) { - w <- which(sapply(alist, function(x) name %in% x)) + w <- which(sapply(alist, \(x) name %in% x)) this_comb <- resolve_comb(name) if (identical(this_comb, "rename")) { @@ -196,7 +196,7 @@ combine.attrs <- function( } else if (identical(this_comb, 0) || identical(this_comb, 0L)) { # ignore: drop the attribute } else { - vals <- lapply(w, function(w2) getval(w2, name)) + vals <- lapply(w, \(w2) getval(w2, name)) attr[[name]] <- apply_attr_combiner(this_comb, vals, type) } } @@ -212,7 +212,7 @@ rename_attr_if_needed <- function(name, w, getval) { if (length(w) == 1) { stats::setNames(list(getval(w, name)), name) } else { - out <- lapply(w, function(w2) getval(w2, name)) + out <- lapply(w, \(w2) getval(w2, name)) names(out) <- paste(name, w, sep = "_") out } @@ -224,7 +224,7 @@ apply_attr_combiner <- function(comb, vals, type) { return(apply_one_combiner(comb, x)) } m <- do.call(cbind, vals) - out <- lapply(seq_len(nrow(m)), function(i) { + out <- lapply(seq_len(nrow(m)), \(i) { x <- m[i, ] x <- x[!is.na(x)] apply_one_combiner(comb, x) @@ -317,7 +317,7 @@ disjoint_union <- function( graphs <- unlist( recursive = FALSE, - lapply(list(...), function(l) { + lapply(list(...), \(l) { if (is_igraph(l)) list(l) else l }) ) @@ -412,7 +412,7 @@ disjoint_union <- function( ) { graphs <- unlist( recursive = FALSE, - lapply(list(...), function(l) { + lapply(list(...), \(l) { if (is_igraph(l)) list(l) else l }) ) @@ -451,13 +451,13 @@ disjoint_union <- function( allnames <- lapply(graphs, vertex_attr, "name") if (keep.all.vertices) { uninames <- unique(unlist(allnames)) - newgraphs <- lapply(graphs, function(g) { + newgraphs <- lapply(graphs, \(g) { g <- g + setdiff(uninames, V(g)$name) permute(g, match(V(g)$name, uninames)) }) } else { uninames <- Reduce(intersect, allnames) - newgraphs <- lapply(graphs, function(g) { + newgraphs <- lapply(graphs, \(g) { g <- g - setdiff(V(g)$name, uninames) permute(g, match(V(g)$name, uninames)) }) @@ -499,7 +499,7 @@ disjoint_union <- function( } else { if (!keep.all.vertices) { minsize <- min(sapply(graphs, vcount)) - graphs <- lapply(graphs, function(g) { + graphs <- lapply(graphs, \(g) { vc <- vcount(g) if (vc > minsize) { g <- g - (minsize + 1):vc diff --git a/R/par.R b/R/par.R index a57b7e8f9dc..36bb5179ef6 100644 --- a/R/par.R +++ b/R/par.R @@ -285,7 +285,7 @@ local_igraph_options <- function(..., .in = parent.frame()) { #' @importFrom pkgconfig set_config get_config get_all_options <- function() { - res <- lapply(names(.igraph.pars), function(n) { + res <- lapply(names(.igraph.pars), \(n) { nn <- paste0("igraph::", n) get_config(nn, fallback = .igraph.pars[[n]]) }) diff --git a/R/plot.R b/R/plot.R index 23a40118460..2c5c210d4c4 100644 --- a/R/plot.R +++ b/R/plot.R @@ -344,7 +344,7 @@ plot.igraph <- function( ## different vertex shapes, do it by "endpoint" shape <- rep(shape, length.out = vcount(graph)) ec <- edge.coords - ec[, 1:2] <- t(sapply(seq(length.out = nrow(el)), function(x) { + ec[, 1:2] <- t(sapply(seq(length.out = nrow(el)), \(x) { .igraph.shapes[[shape[el[x, 1]]]]$clip( edge.coords[x, , drop = FALSE], el[x, , drop = FALSE], @@ -352,7 +352,7 @@ plot.igraph <- function( end = "from" ) })) - ec[, 3:4] <- t(sapply(seq(length.out = nrow(el)), function(x) { + ec[, 3:4] <- t(sapply(seq(length.out = nrow(el)), \(x) { .igraph.shapes[[shape[el[x, 2]]]]$clip( edge.coords[x, , drop = FALSE], el[x, , drop = FALSE], @@ -388,7 +388,7 @@ plot.igraph <- function( compute.bezier <- function(cp, points) { dt <- seq(0, 1, by = 1 / (points - 1)) - sapply(dt, function(t) point.on.cubic.bezier(cp, t)) + sapply(dt, \(t) point.on.cubic.bezier(cp, t)) } plot.bezier <- function( @@ -588,7 +588,7 @@ plot.igraph <- function( loop_angles <- seq(0, 2 * pi, length.out = n_loops + 1)[-1] gap_span <- 2 * pi } else { - angles <- sapply(incident_edges, function(e) { + angles <- sapply(incident_edges, \(e) { ends_e <- ends(graph, e, names = FALSE) other <- if (as.numeric(ends_e[1]) == v) { as.numeric(ends_e[2]) @@ -786,7 +786,7 @@ plot.igraph <- function( ecex <- rep(ecex, length.out = en) invisible(mapply( - function(x, y, label, col, family, font, cex) { + \(x, y, label, col, family, font, cex) { text( x, y, @@ -815,7 +815,7 @@ plot.igraph <- function( if (length(unique(shape)) == 1) { .igraph.shapes[[shape[1]]]$plot(layout, params = params) } else { - sapply(seq(length.out = vcount(graph)), function(x) { + sapply(seq(length.out = vcount(graph)), \(x) { .igraph.shapes[[shape[x]]]$plot( layout[x, , drop = FALSE], v = x, @@ -844,7 +844,7 @@ plot.igraph <- function( # Draw vertex labels invisible(mapply( - function(x0, y0, lbl, col, fam, fnt, cex, srt, adj) { + \(x0, y0, lbl, col, fam, fnt, cex, srt, adj) { text( x0, y0, diff --git a/R/plot.common.R b/R/plot.common.R index 9fb2c5783f6..eae88929cac 100644 --- a/R/plot.common.R +++ b/R/plot.common.R @@ -640,7 +640,7 @@ i.get.arrow.mode <- function(graph, arrow.mode = NULL) { if (is.character(arrow.mode)) { arrow.mode <- map_dbl( arrow.mode, - function(x) { + \(x) { switch(x, "<" = 1, "<-" = 1, ">" = 2, "->" = 2, "<>" = 3, "<->" = 3, 0) } ) @@ -772,7 +772,7 @@ curve_multiple <- function( # END GENERATED ARG_HANDLE el <- apply(as_edgelist(graph, names = FALSE), 1, paste, collapse = ":") - ave(rep(NA, length(el)), el, FUN = function(x) { + ave(rep(NA, length(el)), el, FUN = \(x) { if (length(x) == 1) { return(0) } else { diff --git a/R/plot.shapes.R b/R/plot.shapes.R index dc1eb672675..83696df19f3 100644 --- a/R/plot.shapes.R +++ b/R/plot.shapes.R @@ -570,7 +570,7 @@ add_shape <- function( vertex.frame.color, vertex.size, vertex.frame.width, - FUN = function(x, y, bg, fg, size, lwd) { + FUN = \(x, y, bg, fg, size, lwd) { symbols( x = x, y = y, @@ -639,7 +639,7 @@ add_shape <- function( (l[, 7] - x0)^2 + (l[, 8] - y0)^2 ) - t(sapply(seq(length.out = nrow(l)), function(x) { + t(sapply(seq(length.out = nrow(l)), \(x) { d[x, ][!v[x, ]] <- Inf m <- which.min(d[x, ]) l[x, c(m * 2 - 1, m * 2)] @@ -725,7 +725,7 @@ add_shape <- function( vertex.frame.color, vertex.size, vertex.frame.width, - FUN = function(x, y, bg, fg, size, lwd) { + FUN = \(x, y, bg, fg, size, lwd) { symbols( x = x, y = y, @@ -774,7 +774,7 @@ add_shape <- function( (l[, 7] - x0)^2 + (l[, 8] - y0)^2 ) - t(sapply(seq(length.out = nrow(l)), function(x) { + t(sapply(seq(length.out = nrow(l)), \(x) { m <- which.min(d[x, ]) l[x, c(m * 2 - 1, m * 2)] })) @@ -871,7 +871,7 @@ add_shape <- function( (l[, 7] - x0)^2 + (l[, 8] - y0)^2 ) - t(sapply(seq(length.out = nrow(l)), function(x) { + t(sapply(seq(length.out = nrow(l)), \(x) { d[x, ][!v[x, ]] <- Inf m <- which.min(d[x, ]) l[x, c(m * 2 - 1, m * 2)] @@ -975,7 +975,7 @@ add_shape <- function( vertex.size[, 1], vertex.size[, 2], vertex.frame.width, - FUN = function(x, y, bg, fg, size, size2, lwd) { + FUN = \(x, y, bg, fg, size, size2, lwd) { symbols( x = x, y = y, @@ -1025,7 +1025,7 @@ add_shape <- function( (l[, 7] - x0)^2 + (l[, 8] - y0)^2 ) - t(sapply(seq(length.out = nrow(l)), function(x) { + t(sapply(seq(length.out = nrow(l)), \(x) { m <- which.min(d[x, ]) l[x, c(m * 2 - 1, m * 2)] })) @@ -1103,7 +1103,7 @@ add_shape <- function( (l[, 3] - x0)^2 + (l[, 4] - y0)^2 ) - t(sapply(seq(length.out = nrow(l)), function(x) { + t(sapply(seq(length.out = nrow(l)), \(x) { m <- which.min(d[x, ]) l[x, c(m * 2 - 1, m * 2)] })) @@ -1349,7 +1349,7 @@ mypie <- function( ## Need to create a separate image for every different vertex color allcols <- unique(vertex.color) - images <- lapply(allcols, function(col) { + images <- lapply(allcols, \(col) { img <- getsphere( spos = c(0.0, 0.0, 10.0), sradius = 7.0, diff --git a/R/print.R b/R/print.R index dd421cf0761..bb37f5f1b79 100644 --- a/R/print.R +++ b/R/print.R @@ -105,7 +105,7 @@ if (length(list) != 0) { cat("+ graph attributes:\n") out <- capture.output({ - lapply(list, function(n) { + lapply(list, \(n) { cat(sep = "", "+ ", n, ":\n") indent_print(graph_attr(x, n), .indent = " ") }) @@ -166,7 +166,7 @@ } if ( vc == 0 || - all(sapply(list, function(v) { + all(sapply(list, \(v) { is.numeric(vertex_attr(x, v)) || is.character(vertex_attr(x, v)) || is.logical(vertex_attr(x, v)) @@ -181,7 +181,7 @@ } else { for (i in ind) { cat(sep = "", "[[", i, "]]\n") - lapply(list, function(n) { + lapply(list, \(n) { cat(sep = "", "[[", i, "]][[", n, "]]\n") print(vertex_attr(x, n, i)) }) @@ -242,7 +242,7 @@ } if ( ec == 0 || - all(sapply(list, function(v) { + all(sapply(list, \(v) { is.numeric(edge_attr(x, v)) | is.character(edge_attr(x, v)) | is.logical(edge_attr(x, v)) @@ -267,9 +267,9 @@ print(tab) } else { i <- 1 - apply(el, 1, function(v) { + apply(el, 1, \(v) { cat(sep = "", "[", ename[i], "] ", v[1], " ", arrow, " ", v[2]) - lapply(list, function(n) { + lapply(list, \(n) { cat(sep = "", "\n[[", i, "]][[", n, "]]\n") print(edge_attr(x, n, i)) }) @@ -446,7 +446,7 @@ print_edge_detail <- function(graph, edges) { ## Wrapping needed mw <- max.ind.width sm <- paste(collapse = "", rep(" ", mw + 4)) - alstr <- lapply(seq_along(al), function(x) { + alstr <- lapply(seq_along(al), \(x) { len <- length(al[[x]]) fac <- rep(1:(len / mpl + 1), each = mpl, length.out = len) nei <- tapply(format(al[[x]], width = mw), fac, paste, collapse = " ") @@ -456,7 +456,7 @@ print_edge_detail <- function(graph, edges) { }) cat(unlist(alstr), sep = "\n") } else { - alstr <- sapply(al, function(x) { + alstr <- sapply(al, \(x) { paste(format(x, width = w), collapse = " ") }) mark <- paste(sep = "", format(ind), arrow) @@ -488,7 +488,7 @@ print_edge_detail <- function(graph, edges) { ind <- tr$ind al <- as_adj_list(x, mode = "out")[ind] - alstr <- sapply(al, function(x) { + alstr <- sapply(al, \(x) { paste(collapse = ", ", vn[x]) }) alstr <- paste(sep = "", format(vn[ind]), arrow, alstr) @@ -861,7 +861,7 @@ print_igraph_attr_summary_cli <- function(x) { labels <- vapply(codes, attr_label_cli, character(1)) parts <- vapply( seq_along(names), - function(i) { + \(i) { nm <- names[i] lbl <- labels[i] cli::format_inline("{.field {nm}} {.cls {lbl}}") diff --git a/R/scan.R b/R/scan.R index fb80dc178cb..6d77460c233 100644 --- a/R/scan.R +++ b/R/scan.R @@ -286,7 +286,7 @@ local_scan <- function( ## General } else { - sapply(V(graph.us), function(x) { + sapply(V(graph.us), \(x) { vei <- neighborhood(graph.us, order = k, nodes = x, mode = mode)[[1]] if (!is.function(FUN)) { FUN <- getFunction(FUN, where = environment()) diff --git a/R/structural-properties.R b/R/structural-properties.R index c2970ebc5a9..89c1406f09f 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -1694,10 +1694,10 @@ shortest_paths <- function( ) if (!is.null(res$vpath)) { - res$vpath <- lapply(res$vpath, function(x) x + 1) + res$vpath <- lapply(res$vpath, \(x) x + 1) } if (!is.null(res$epath)) { - res$epath <- lapply(res$epath, function(x) x + 1) + res$epath <- lapply(res$epath, \(x) x + 1) } if (!is.null(res$predecessors)) { res$predecessors <- res$predecessors + 1 @@ -2945,7 +2945,7 @@ ego <- function( as.numeric(mode), mindist ) - res <- lapply(res, function(x) x + 1) + res <- lapply(res, \(x) x + 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) diff --git a/R/tkplot.R b/R/tkplot.R index 9342a284939..2848f80dd9e 100644 --- a/R/tkplot.R +++ b/R/tkplot.R @@ -586,7 +586,7 @@ tk_close <- function( #' @export tk_off <- function() { # nocov start - eapply(.tkplot.env, function(tkp) { + eapply(.tkplot.env, \(tkp) { tcltk::tkdestroy(tkp$top) }) rm(list = ls(.tkplot.env), envir = .tkplot.env) @@ -1046,7 +1046,7 @@ tk_canvas <- function(tkp.id) { labels <- i.get.labels(tkp$graph, tkp$labels) mapply( - function(v, l, x, y) .tkplot.create.vertex(tkp.id, v, l, x, y), + \(v, l, x, y) .tkplot.create.vertex(tkp.id, v, l, x, y), 1:n, labels, tkp$coords[, 1], @@ -1117,7 +1117,7 @@ tk_canvas <- function(tkp.id) { tkp <- .tkplot.get(tkp.id) n <- vcount(tkp$graph) mapply( - function(v, x, y) .tkplot.update.vertex(tkp.id, v, x, y), + \(v, x, y) .tkplot.update.vertex(tkp.id, v, x, y), 1:n, tkp$coords[, 1], tkp$coords[, 2] @@ -1258,7 +1258,7 @@ tk_canvas <- function(tkp.id) { tkp <- .tkplot.get(tkp.id) edgematrix <- as_edgelist(tkp$graph, names = FALSE) mapply( - function(from, to, id) .tkplot.create.edge(tkp.id, from, to, id), + \(from, to, id) .tkplot.create.edge(tkp.id, from, to, id), edgematrix[, 1], edgematrix[, 2], seq_len(nrow(edgematrix)) @@ -1462,7 +1462,7 @@ tk_canvas <- function(tkp.id) { vparams <- tkp$params$vertex.params vparams[vids, "vertex.size"] <- newsize .tkplot.set(tkp.id, "params$vertex.params", vparams) - sapply(vids, function(id) { + sapply(vids, \(id) { .tkplot.update.vertex(tkp.id, id, tkp$coords[id, 1], tkp$coords[id, 2]) }) } @@ -1494,7 +1494,7 @@ tk_canvas <- function(tkp.id) { tcltk::tkgrid(OK.but) tcltk::tkwait.window(dialog) - retval <- lapply(retval, function(v) { + retval <- lapply(retval, \(v) { eval(parse(text = paste("c(", v, ")"))) }) return(retval) @@ -1578,10 +1578,10 @@ tk_canvas <- function(tkp.id) { .tkplot.select.some.edges <- function(tkp.id, from, to) { canvas <- .tkplot.get(tkp.id, "canvas") - fromtags <- sapply(from, function(i) { + fromtags <- sapply(from, \(i) { paste(sep = "", "from-", i) }) - totags <- sapply(from, function(i) { + totags <- sapply(from, \(i) { paste(sep = "", "to-", i) }) edges <- as.numeric(tcltk::tkfind(canvas, "withtag", "edge")) @@ -1721,7 +1721,7 @@ tk_canvas <- function(tkp.id) { canvas <- .tkplot.get(tkp.id, "canvas") tkids <- as.numeric(tcltk::tkfind(canvas, "withtag", "vertex&&selected")) - ids <- sapply(tkids, function(tkid) { + ids <- sapply(tkids, \(tkid) { tags <- as.character(tcltk::tkgettags(canvas, tkid)) id <- as.numeric(substring(tags[pmatch("v-", tags)], 3)) id @@ -1734,7 +1734,7 @@ tk_canvas <- function(tkp.id) { canvas <- .tkplot.get(tkp.id, "canvas") tkids <- as.numeric(tcltk::tkfind(canvas, "withtag", "edge&&selected")) - ids <- sapply(tkids, function(tkid) { + ids <- sapply(tkids, \(tkid) { tags <- as.character(tcltk::tkgettags(canvas, tkid)) id <- as.numeric(substring(tags[pmatch("edge-", tags)], 6)) id @@ -1754,7 +1754,7 @@ tk_canvas <- function(tkp.id) { select.menu, "command", label = "Select all vertices", - command = function() { + command = \() { .tkplot.deselect.all(tkp.id) .tkplot.select.all.vertices(tkp.id) } @@ -1763,7 +1763,7 @@ tk_canvas <- function(tkp.id) { select.menu, "command", label = "Select all edges", - command = function() { + command = \() { .tkplot.deselect.all(tkp.id) .tkplot.select.all.edges(tkp.id) } @@ -1772,7 +1772,7 @@ tk_canvas <- function(tkp.id) { select.menu, "command", label = "Select some vertices...", - command = function() { + command = \() { vids <- .tkplot.get.numeric.vector("Select vertices") .tkplot.select.some.vertices(tkp.id, vids[[1]]) } @@ -1781,7 +1781,7 @@ tk_canvas <- function(tkp.id) { select.menu, "command", label = "Select some edges...", - command = function() { + command = \() { fromto <- .tkplot.get.numeric.vector( "Select edges from vertices", "to vertices" @@ -1794,7 +1794,7 @@ tk_canvas <- function(tkp.id) { select.menu, "command", label = "Deselect everything", - command = function() { + command = \() { .tkplot.deselect.all(tkp.id) } ) @@ -1805,12 +1805,12 @@ tk_canvas <- function(tkp.id) { .tkplot.layout.menu <- function(tkp.id, main.menu) { layout.menu <- tcltk::tkmenu(main.menu) - sapply(.tkplot.getlayoutlist(), function(n) { + sapply(.tkplot.getlayoutlist(), \(n) { tcltk::tkadd( layout.menu, "command", label = .tkplot.getlayoutname(n), - command = function() { + command = \() { .tkplot.layout.dialog(tkp.id, n) } ) @@ -2006,7 +2006,7 @@ tk_canvas <- function(tkp.id) { column = 0 ) tcltk::tkgrid( - tcltk::tkbutton(dialog, text = "Cancel", command = function() { + tcltk::tkbutton(dialog, text = "Cancel", command = \() { tcltk::tkdestroy(dialog) invisible(TRUE) }), diff --git a/R/topology.R b/R/topology.R index 1069c076de5..c88e64d9e8d 100644 --- a/R/topology.R +++ b/R/topology.R @@ -145,7 +145,7 @@ graph.get.isomorphisms.vf2 <- function( edge_color2 = edge.color2 ) - lapply(res, function(.x) V(graph2)[.x + 1]) + lapply(res, \(.x) V(graph2)[.x + 1]) } #' @export @@ -166,7 +166,7 @@ graph.get.subisomorphisms.vf2 <- function( edge_color2 = edge.color2 ) - lapply(res, function(.x) V(graph1)[.x + 1]) + lapply(res, \(.x) V(graph1)[.x + 1]) } #' @export @@ -262,7 +262,7 @@ graph.subisomorphic.lad <- function( "{.arg domains} length and {.arg pattern} number of vertices must match." ) } - domains <- lapply(domains, function(x) as_igraph_vs(target, x) - 1) + domains <- lapply(domains, \(x) as_igraph_vs(target, x) - 1) } on.exit(.Call(Rx_igraph_finalizer)) @@ -285,7 +285,7 @@ graph.subisomorphic.lad <- function( } } if (all.maps) { - res$maps <- lapply(res$maps, function(.x) V(target)[.x + 1]) + res$maps <- lapply(res$maps, \(.x) V(target)[.x + 1]) } res diff --git a/R/utils-s3.R b/R/utils-s3.R index 0958f90863a..e1b35a430d0 100644 --- a/R/utils-s3.R +++ b/R/utils-s3.R @@ -53,7 +53,7 @@ s3_register <- function(generic, class, method = NULL) { } # Always register hook in case package is later unloaded & reloaded - setHook(packageEvent(package, "onLoad"), function(...) { + setHook(packageEvent(package, "onLoad"), \(...) { register() }) @@ -107,9 +107,9 @@ s3_register <- function(generic, class, method = NULL) { format_msg <- function(x) paste(x, collapse = "\n") switch(fn, is_interactive = return(is_interactive_compat), - abort = return(function(msg) stop(format_msg(msg), call. = FALSE)), - warn = return(function(msg) warning(format_msg(msg), call. = FALSE)), - inform = return(function(msg) message(format_msg(msg))) + abort = return(\(msg) stop(format_msg(msg), call. = FALSE)), + warn = return(\(msg) warning(format_msg(msg), call. = FALSE)), + inform = return(\(msg) message(format_msg(msg))) ) stop(sprintf("Internal error in rlang shims: Unknown function `%s()`.", fn)) diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index bfb5ca69ed8..0610cc7bd17 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -431,8 +431,8 @@ CLOSURE: rlang::error_cnd(message = "Callback returned a value different from TRUE or FALSE") } }, - error = function(e) e, - interrupt = function(e) e + error = \(e) e, + interrupt = \(e) e ) } } else { @@ -460,7 +460,7 @@ ISOMORPHISM_FUNC: HEADER: ~ VERTEXSET_LIST: - CALL: if (!is.null(%I%)) lapply(%I%, function(.x) .x - 1) + CALL: if (!is.null(%I%)) lapply(%I%, \(.x) .x - 1) INCONV: IN: |- if (!is.null(%I%) && !is.list(%I%)) { @@ -476,7 +476,7 @@ VERTEXSET_LIST: } EDGESET_LIST: - CALL: lapply(%I%, function(.x) .x - 1) + CALL: lapply(%I%, \(.x) .x - 1) OUTCONV: OUT: |- if (igraph_opt("return.vs.es")) { @@ -516,7 +516,7 @@ BLISSSH: BLISSINFO: {} ADJLIST: - INCONV: '%I% <- lapply(%I%, function(x) as.numeric(x) - 1)' + INCONV: '%I% <- lapply(%I%, \(x) as.numeric(x) - 1)' COMMCMP: DEFAULT: @@ -743,7 +743,7 @@ GRAPH_PTR_LIST: if (!is.list(%I%)) { cli::cli_abort("{.arg %I%} must be a list of igraph objects") } - %I% <- lapply(%I%, function(g) { + %I% <- lapply(%I%, \(g) { if (!inherits(g, "igraph")) { cli::cli_abort("{.arg %I%} must be a list of igraph objects") } @@ -755,7 +755,7 @@ MATRIX_LIST: if (!is.list(%I%)) { cli::cli_abort("{.arg %I%} must be a list of matrices") } - %I% <- lapply(%I%, function(m) { + %I% <- lapply(%I%, \(m) { if (!is.matrix(m)) { cli::cli_abort("{.arg %I%} must be a list of matrices") }