Is there a simple way to to make a consumableList of a subset of the larger list?

I’d like something like the following

originalList
  A
  B
  C
  D

[a = originalList.selectmany(2).consumableList]

in my dream, [a] should be a consumable list of two random elements from originalList.

Thanks!

  • Koto@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    6 months ago

    Yes, it’s possible. The correct syntax would be [a = originalList.consumableList.selectMany(2)] . Then, we’ll need to make a list of that slice by using createPerchanceTree() with the correct escape characters. The function works like this: [newList = createPerchanceTree("slicedList\n\ta\n\tb").slicedList] [newList]

    • danMiller@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 months ago

      If I understand this correctly, I think I lose having a consumable list as the final output. But it got me on the right track I think. THANKYOU!

      I’m working with this now, which seems to produce a functional consumable list derived from a slice of the original list.

      thanks again, I hadn’t stumbled across the createPerchanceTree command in the tutorials.

      OriginalList
        d
        c
        x
        y
        z
      
      //calls consumableList here just to prevent duplication
      a = \{  [OriginalList.consumableList.selectMany(2).joinItems("|")]  \}
      
      output
        //converts the selectmany product to a consumableList
        [newList = createPerchanceTree("slicedList =" + a ).slicedList.consumableList] [newList] [newList]  
      
      
      
      
      
      • Koto@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 months ago

        You won’t be losing consumable list on that created list, as you can .consumableList it again. Judging by your code, you figured it out!