Spyke
perchance·Perchance - Create a Random Text GeneratorbyAshenthorn

Prepending single list items... best way?

I'm working on my prompt generator, and I need to prepend my list items with a string: "by " (including the space).

I set this in the joinItems function of my output: joinItems(", by ") ... but this (obviously) doesn't include the first item of the list.

So I defined a prefix variable "pp = by"

Now my output is:

$output = [pp] [fa = defaultPainters.selectAll.joinItems(", by ")]

This works, but it seems a little kludgy - is there a better/preferred way?

Thanks for any tips!

Prepending single list items... best way?https://perchance.org/incitu8t9b#editOpen linkView original on lemmy.world
lemmy.world

Can you give an expected output of the list, and some example lists? Didn't see the linked generator lmaooo.

2
VioneTreply
lemmy.world

A simple solution is just $output = by [fa = defaultPainter.selectAll.joinItems(", by ")], you don't need to use a list if you are only outputting text.

2

Yeah.. I guess I had it right, except I didn't really need to set the variable. It seemed like the right thing to do since I needed to use it for two different lists... but typing "by " in both outputs does the same thing, without any extra characters. lol. Thanks!

2

You reached the end

Prepending single list items... best way? | Spyke