Working with lists in TiddlyWiki

Here are several approaches:

  1. with a $set widget
<$set name="list1" filter="a b c d e f g h i j">
... <<list1>>
</$set>

<$set filter= is the only option that automatically saves a title list (adding whitespace and square brackets between its outputs as necessary). The other options all make use of +[format:titlelist[]join[ ]] (essentially, the inverse of enlist-input[]) to save the list as a single string.

  • format:titlelist[] wraps each of its inputs in square brackets if that input contains a space. If you are sure that none of your list items will contain spaces (as in these examples) you can technically omit it and use join[ ] only… but it doesn’t hurt to include it even if it’s not needed.
  1. with a $let widget
<$let list2={{{ A B C D E F G H I J +[format:titlelist[]join[ ]] }}}>
... <<list2>>
</$let>
  1. with a function
\function list3() 1 2 3 4 5 6 7 8 9 10 +[format:titlelist[]join[ ]]

... <<list3>>
  1. with a $list variable
<$list filter="0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.10 +[format:titlelist[]join[ ]]" variable="list4">
... <<list4>>
</$list>

Demoing all four techniques:


Note that because we’ve saved all the results of the list4 example as a single title list, this $list widget only loops once, rather than the ten times we’d expect without +[format:titlelist[]join[ ]].

Re: your Python example: @rmunn proposed a new filter operator that would simplify interleaving lists (original GitHub issue; more recent Talk discussion), though it seems to have stalled after debate about what sort of behavior users would expect. However, we can currently do this sort of thing with a helper function: