R/get_suit.R

Defines functions get_suit

Documented in get_suit

#' Retrieve cards of specified suit.
#'
#' @param cards A list of objects of the S4 class `card`.
#' @param suit A string of the name of the suit to retain.
#' The first letter must be a capital.
#'
#' @return A list containing all cards of the specified suit.
#' @export
#'
get_suit <- function(cards,suit){
  n <- length(cards)
  remove <- c()
  for (i in 1:n){
    if (cards[[i]]@suit != suit) remove <- c(remove,i)
  }
  if(!is.null(remove[1])) cards <- cards[-remove]
  return(cards)
}
dfcorbin/pokersim2 documentation built on Jan. 15, 2020, 12:20 a.m.