Hi all! Total Perchance newbie here, so I sincerely apologize if this is obvious/already been answered. Been having fun tinkering with it, but got this weird bug…

I’ve got a bit of a scuffed loop set up to select a word for each letter input by the user. However, the output of filterList() isn’t happy with my using selectOne on it, producing an extra two undefineds for some strange reason. I don’t know if it’s maybe related to the way I’m filtering the list or some other bug? Anyone know why this is happening/a better way to do it?

Thanks for all y’all’s help!

  • 🎲VioneT@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 days ago

    You can use the select-until-plugin instead of filter-list-plugin.

    selectUntil = {import:select-until-plugin}
    
    count = 0
    
    output
      [count = 0, acronymLoop]
      // count = 0, to reset the counter for each generation
      
    acronymLoop
      [word = count < acronym.length ? (n = selectUntil(noun, i => matchFirstChar(i, acronym.charAt(count))), count++, "<span contenteditable>" + emphasizeFirstChar(n) + "</span> " + acronymLoop) : '']
    
      // Instead of filter list, we use the select-until-plugin in which the 'test' to be used was the `matchFirstChar` function that you already have.
      // We start at 0, then count up (`count++`)
      // Then the check is now `count < acronym.length` instead of `count <= acronym.length` since we use zero-indexing with `charAt`.