# How can I create a List from CL Layer

I am trying to create the Ace or King game for a Statistics class, and I would like the results of each round of drawn cards to populate the result in the table. I am thinking the easiest way to populate the Win or Loss in the table is to Access the element a List of results. Is there a way to populate a list with a 1 or 2 each time a round is finished for a total of 15 rounds? I have not been able to find any examples to help me modify the code.

Here is my activity

Here’s a solution, but I guarantee there’s a better method by relying on the graphing calculator more.

Add this to the graph component:

``````number(`W`): when Card.number(`n`)=1 and ((Card.number(`E[1]`)=50 and Card.number(`E[3]`)=50) or (Card.number(`E[2]`)=50 and Card.number(`E[4]`)=50 and Card.number(`E[5]`)=50)) 1 otherwise 2

numberList(`w`): button1.history("w")
``````

Add this to the button component:

``````capture("w"): Card.number(`W`)
``````

And finally, add this to the table:

``````cellContent(1,2): when button1.pressCount>1 and Card.numberList(`w`).elementAt(2)=1 "Win" when button1.pressCount>1 and Card.numberList(`w`).elementAt(2)=2 "Lose" otherwise ""
cellContent(2,2): when button1.pressCount>4 and Card.numberList(`w`).elementAt(5)=1 "Win" when button1.pressCount>4 and Card.numberList(`w`).elementAt(5)=2 "Lose" otherwise ""
cellContent(3,2): when button1.pressCount>7 and Card.numberList(`w`).elementAt(8)=1 "Win" when button1.pressCount>7 and Card.numberList(`w`).elementAt(8)=2 "Lose" otherwise ""
cellContent(4,2): when button1.pressCount>10 and Card.numberList(`w`).elementAt(11)=1 "Win" when button1.pressCount>10 and Card.numberList(`w`).elementAt(11)=2 "Lose" otherwise ""
cellContent(5,2): when button1.pressCount>13 and Card.numberList(`w`).elementAt(14)=1 "Win" when button1.pressCount>13 and Card.numberList(`w`).elementAt(14)=2 "Lose" otherwise ""
cellContent(6,2): when button1.pressCount>16 and Card.numberList(`w`).elementAt(17)=1 "Win" when button1.pressCount>16 and Card.numberList(`w`).elementAt(17)=2 "Lose" otherwise ""
cellContent(7,2): when button1.pressCount>19 and Card.numberList(`w`).elementAt(20)=1 "Win" when button1.pressCount>19 and Card.numberList(`w`).elementAt(20)=2 "Lose" otherwise ""
cellContent(8,2): when button1.pressCount>22 and Card.numberList(`w`).elementAt(23)=1 "Win" when button1.pressCount>22 and Card.numberList(`w`).elementAt(23)=2 "Lose" otherwise ""
cellContent(9,2): when button1.pressCount>25 and Card.numberList(`w`).elementAt(26)=1 "Win" when button1.pressCount>25 and Card.numberList(`w`).elementAt(26)=2 "Lose" otherwise ""
cellContent(10,2): when button1.pressCount>28 and Card.numberList(`w`).elementAt(29)=1 "Win" when button1.pressCount>28 and Card.numberList(`w`).elementAt(29)=2 "Lose" otherwise ""
cellContent(11,2): when button1.pressCount>31 and Card.numberList(`w`).elementAt(32)=1 "Win" when button1.pressCount>31 and Card.numberList(`w`).elementAt(32)=2 "Lose" otherwise ""
cellContent(12,2): when button1.pressCount>34 and Card.numberList(`w`).elementAt(35)=1 "Win" when button1.pressCount>34 and Card.numberList(`w`).elementAt(35)=2 "Lose" otherwise ""
cellContent(13,2): when button1.pressCount>37 and Card.numberList(`w`).elementAt(38)=1 "Win" when button1.pressCount>37 and Card.numberList(`w`).elementAt(38)=2 "Lose" otherwise ""
cellContent(14,2): when button1.pressCount>40 and Card.numberList(`w`).elementAt(41)=1 "Win" when button1.pressCount>40 and Card.numberList(`w`).elementAt(41)=2 "Lose" otherwise ""
cellContent(15,2): when button1.pressCount>43 and Card.numberList(`w`).elementAt(44)=1 "Win" when button1.pressCount>43 and Card.numberList(`w`).elementAt(44)=2 "Lose" otherwise ""
``````

This was a fun challenge, so I kept working on it.

This works the same as the previous suggestion, but it uses less CL and more of the calculator. I’ll just share the link so you can take a look at the differences. I heavily commented the changes in the graphing calculator and made comments on any CL that is needed/changed.

Thank you so much. I knew there was a way to do it with a capture feature, but I have not wrapped my head around how to code those yet. This is so much better than the student having to select win or lose from a MC question and having 15 of them.