How to perform a check on a permutation “on-the-fly” without storing the result in R
问题 Assume we have the following permutations of the letters, "a", "b", and "c": library(combinat) do.call(rbind, permn(letters[1:3])) # [,1] [,2] [,3] # [1,] "a" "b" "c" # [2,] "a" "c" "b" # [3,] "c" "a" "b" # [4,] "c" "b" "a" # [5,] "b" "c" "a" # [6,] "b" "a" "c" Is it possible to perform some function on a given permutation "on-the-fly" (i.e., a particular row) without storing the result? That is, if the row == "a" "c" "b" or row == "b" "c" "a" , do not store the result. The desired result in