Displaying 1 result from an estimated 1 matches for "num_decks".
2010 Mar 16
1
Changing global variables from functions
...declared variable that doesn't update it when I change it
in a function. For example when I run the following function
>deckn<-NULL
>deck1<-1 #52 card deck
>deck<-function()
{
#Creating a standard deck
deck1<-c(1:52)
deckn<-deck1
#Creating n decks
for (i in 2:num_decks)
{
deckn<-c(deckn,52*i+deck1-1)
}
}
>deckn
>NULL
it returns NULL for deckn instead of a vector of values. Is there an easy
fix to update deckn in the function so that it outputs a vector of values (
I don't wish the function to return a value just update the current one)?...