I have a table with 13 entries, but based on a variable (values -1, 0, 1) I would want to return from items 1-11, 2-12, or 3-13 respectively. So the variable value would essentially tell the generator to ignore some entries from the head or tail of the list. Is there a way to accomplish this in Perchance?

  • @wthit56
    link
    English
    122 days ago

    There are a couple of ways… One is using odds to prevent/allow items from being selected.

    But, thinking about this a different way, you can make groups with the name -1, 0, and 1, and grab a group by name–with your variable.

    Each item and group/list is a property of its parent:

    parent
      child1
      child2
    

    You can grab child1 by using the code parent.child1. But also if you have a variable prop_name with the value "child1" you can use that to grab a property of that name using the code parent[prop_name]. Even if the variable’s value is a number like -1, 0, or 1, you can use it the same way.

    I’ve demonstrated both methods here: https://perchance.org/679qmltn63#edit