We’re rewarding the question askers & reputations are being recalculated! Read more.
3 deleted 1 characters in body; edited tags; edited title
source | link

picking Picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

AsumeAssume a function

getRandomItem[l_List]

I tried playing with downvaluesdown-values but that doesn't work.

Calling getRandomItem[data1]getRandomItem[data1] two times would give (e.g)

   {1} and {3}

 . Calling getRandomItem[data2]getRandomItem[data2] two times would give (e.g)

   {15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So, basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Asume function

getRandomItem[l_List]

I tried playing with downvalues but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)

 {1} and {3}

  Calling getRandomItem[data2] two times would give (e.g)

 {15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So, basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

Picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Assume a function

getRandomItem[l_List]

I tried playing with down-values but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)  {1} and {3}. Calling getRandomItem[data2] two times would give (e.g)  {15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So, basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

    Tweeted twitter.com/#!/StackMma/status/190094859674202112
2 formatted code; added a comma
source | link

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Asume function

getRandomItem[l_List]

I tried playing with downvalues but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)

{1}{1} and {3}{3}

Calling getRandomItem[data2] two times would give (e.g)

{15}{15} and {20}{20}

At the end as stated before when all items are chosen both getRandomItem[data1]getRandomItem[data1] and getRandomItem[data2]getRandomItem[data2] should return {}{}.

I would like to do that without declaring data1data1 and data2data2 as global variables nor do I which to change/alter them. So, basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Asume function

getRandomItem[l_List]

I tried playing with downvalues but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)

{1} and {3}

Calling getRandomItem[data2] two times would give (e.g)

{15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Asume function

getRandomItem[l_List]

I tried playing with downvalues but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)

{1} and {3}

Calling getRandomItem[data2] two times would give (e.g)

{15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So, basically I presume the function itself should remember which data has been given to it and where it had left the previous time.

1
source | link

picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. Basically like emptying a bucket full of eggs one at a time.

Suppose I have two lists:

data1 = Range[10];
data2 = Range[20];

Asume function

getRandomItem[l_List]

I tried playing with downvalues but that doesn't work.

Calling getRandomItem[data1] two times would give (e.g)

{1} and {3}

Calling getRandomItem[data2] two times would give (e.g)

{15} and {20}

At the end as stated before when all items are chosen both getRandomItem[data1] and getRandomItem[data2] should return {}.

I would like to do that without declaring data1 and data2 as global variables nor do I which to change/alter them. So basically I presume the function itself should remember which data has been given to it and where it had left the previous time.