Removing or adding multiple items in list at one time


Author
Message
Andrew Papale
Andrew Papale
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
Andrew Papale - 10/10/2023
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


> Is it possible to append or remove more than one item to a list at a time?

No, not with a single function call. The appenditem() function takes one argument -- the one item to append at that time -- , not multiple.

Depending on what exactly you want to do, writing a while() loop may help you. For example, suppose you have some list A containg some large amount of items, and you want to pick  some subset of those items at random and put them in another list. Then you can do something like this:

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1-8 = test_list;
]
</block>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    var i = 0;
    while (i < 3) {
        list.test_list.appenditem(list.a.nextvalue);
        i += 1;
    };
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
/ selectionrate = always
</list>

<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list test_list>
</list>




Edited 7 Months Ago by Dave
Andrew Papale
Andrew Papale
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


> Is it possible to append or remove more than one item to a list at a time?

No, not with a single function call. The appenditem() function takes one argument -- the one item to append at that time -- , not multiple.

Depending on what exactly you want to do, writing a while() loop may help you. For example, suppose you have some list A containg some large amount of items, and you want to pick  some subset of those items at random and put them in another list. Then you can do something like this:

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1-8 = test_list;
]
</block>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    var i = 0;
    while (i < 3) {
        list.test_list.appenditem(list.a.nextvalue);
        i += 1;
    };
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
/ selectionrate = always
</list>

<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list test_list>
</list>




Excellent, I did not know loops were an option!  Can I use a for loop instead?
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
Andrew Papale - 10/10/2023
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


> Is it possible to append or remove more than one item to a list at a time?

No, not with a single function call. The appenditem() function takes one argument -- the one item to append at that time -- , not multiple.

Depending on what exactly you want to do, writing a while() loop may help you. For example, suppose you have some list A containg some large amount of items, and you want to pick  some subset of those items at random and put them in another list. Then you can do something like this:

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1-8 = test_list;
]
</block>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    var i = 0;
    while (i < 3) {
        list.test_list.appenditem(list.a.nextvalue);
        i += 1;
    };
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
/ selectionrate = always
</list>

<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list test_list>
</list>




Excellent, I did not know loops were an option!  Can I use a for loop instead?

No, there are only while() loops in Inquisit 6. However, every for-loop can be expressed as a while() loop (and vice versa).
Andrew Papale
Andrew Papale
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


> Is it possible to append or remove more than one item to a list at a time?

No, not with a single function call. The appenditem() function takes one argument -- the one item to append at that time -- , not multiple.

Depending on what exactly you want to do, writing a while() loop may help you. For example, suppose you have some list A containg some large amount of items, and you want to pick  some subset of those items at random and put them in another list. Then you can do something like this:

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1-8 = test_list;
]
</block>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    var i = 0;
    while (i < 3) {
        list.test_list.appenditem(list.a.nextvalue);
        i += 1;
    };
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
/ selectionrate = always
</list>

<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list test_list>
</list>




Excellent, I did not know loops were an option!  Can I use a for loop instead?

No, there are only while() loops in Inquisit 6. However, every for-loop can be expressed as a while() loop (and vice versa).

Here's what I was trying to do, if it is useful to anyone looking, this is a nice little function to get values within the 25%ile and 75%ile of a list:

<expt main1>
/ blocks = [
1 = experiment;
]
</expt>

<block experiment>
/ trials = [
1-8 = test_list;
]
</block>

<values>
/ i = NULL;
/ lower_quartile = NULL;
/ upper_quartile = NULL;

</values>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    values.i = 0;
    while (values.i < 10) {
            list.a.nextvalue;
            if (list.a.currentvalue < list.a.median){
                list.lower_half.appenditem(list.a.currentvalue);
            } else if (list.a.currentvalue > list.a.median){
                list.upper_half.appenditem(list.a.currentvalue);
            }
            values.i += 1;
    };
    values.lower_quartile = list.lower_half.median;
    values.upper_quartile = list.upper_half.median;
    
    while (list.test_list.itemcount < 1){
        list.a.nextvalue;
        if (list.a.currentvalue >= values.lower_quartile && list.a.currentvalue <= values.upper_quartile){
            list.test_list.appenditem(list.a.currentvalue);
        }
    };
    
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a> // list doesn't need to be sorted
/ items = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
/ selectionrate = always
</list>

<text test_list>
/ items = ("iterations = <%values.i%> [<%list.test_list.items.1%>]")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list lower_half>
</list>

<list upper_half>
</list>

<list test_list>
</list>



Andrew Papale
Andrew Papale
Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)Partner Member (807 reputation)
Group: Forum Members
Posts: 62, Visits: 230
Andrew Papale - 10/10/2023
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dave - 10/10/2023
Andrew Papale - 10/10/2023
Dear Inquisit Team,

Is it possible to append or remove more than one item to a list at a time?

e.g. This script compiles and runs but does not append (1,2,5) to the list.

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1 = test_list;
]
</block>

< trial test_list>
/ ontrialbegin = [
    list.test_list.appenditem(1,2,5);
]

/ stimulusframes = [1 = test_list]
/ timeout = 5000;

</trial>


<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)

</text>

<list test_list>
/ items = ()
</list>


> Is it possible to append or remove more than one item to a list at a time?

No, not with a single function call. The appenditem() function takes one argument -- the one item to append at that time -- , not multiple.

Depending on what exactly you want to do, writing a while() loop may help you. For example, suppose you have some list A containg some large amount of items, and you want to pick  some subset of those items at random and put them in another list. Then you can do something like this:

<expt main1>
/ blocks =[
    1 = experiment;
]
</expt>

<block experiment>
/ trials = [
    1-8 = test_list;
]
</block>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    var i = 0;
    while (i < 3) {
        list.test_list.appenditem(list.a.nextvalue);
        i += 1;
    };
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a>
/ items = ("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
/ selectionrate = always
</list>

<text test_list>
/ items = ("<%list.test_list.items.1%> <%list.test_list.items.2%> <%list.test_list.items.3%>")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list test_list>
</list>




Excellent, I did not know loops were an option!  Can I use a for loop instead?

No, there are only while() loops in Inquisit 6. However, every for-loop can be expressed as a while() loop (and vice versa).

Here's what I was trying to do, if it is useful to anyone looking, this is a nice little function to get values within the 25%ile and 75%ile of a list:

<expt main1>
/ blocks = [
1 = experiment;
]
</expt>

<block experiment>
/ trials = [
1-8 = test_list;
]
</block>

<values>
/ i = NULL;
/ lower_quartile = NULL;
/ upper_quartile = NULL;

</values>

<trial test_list>
/ ontrialbegin = [
    list.test_list.reset();
    values.i = 0;
    while (values.i < 10) {
            list.a.nextvalue;
            if (list.a.currentvalue < list.a.median){
                list.lower_half.appenditem(list.a.currentvalue);
            } else if (list.a.currentvalue > list.a.median){
                list.upper_half.appenditem(list.a.currentvalue);
            }
            values.i += 1;
    };
    values.lower_quartile = list.lower_half.median;
    values.upper_quartile = list.upper_half.median;
    
    while (list.test_list.itemcount < 1){
        list.a.nextvalue;
        if (list.a.currentvalue >= values.lower_quartile && list.a.currentvalue <= values.upper_quartile){
            list.test_list.appenditem(list.a.currentvalue);
        }
    };
    
]
/ stimulusframes = [1 = test_list]
/ validresponse = (57)
</trial>

<list a> // list doesn't need to be sorted
/ items = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
/ selectionrate = always
</list>

<text test_list>
/ items = ("iterations = <%values.i%> [<%list.test_list.items.1%>]")
/ position = (50%, 50%)
/ size = (50%, 50%)
</text>

<list lower_half>
</list>

<list upper_half>
</list>

<list test_list>
</list>



values.i < 10 should be values.i < list.a.itemcount
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search