R/remove_cards.R

Defines functions remove_cards

Documented in remove_cards

#' Remove a list of specified cards from another list of specified cards.
#'
#' @param cards A list of objects from the S4 class 'card'.
#' @param remove A list of objects from the S4 class 'card' which will be
#' removed from the list.
#'
#' @return A list of objects from the S4 class 'card'.
#' @export
#'
#' @examples
remove_cards <- function(cards,remove){
  to_remove <- c()
  for (i in 1:length(remove)){
    for (j in 1:length(cards)){
      if(
        (remove[[i]]@suit == cards[[j]]@suit) && (remove[[i]]@value == cards[[j]]@value)
      ) to_remove <- c(to_remove,j)
    }
  }
  cards<- cards[-to_remove]
  return(cards)
}

set.seed(1234)
cards <- new_cards(5,new_deck())[-6]
cards[[4]]@value <- 7
cards <- remove_cards(cards,exists_n_kind(cards,3)$cards)
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.