How to process two lists in parallel?

79 views
Skip to first unread message

Erwan

unread,
Dec 26, 2020, 11:22:31 AM12/26/20
to TiddlyWiki

Hi everyone,

I'm trying to create several tiddlers which contain two fields coming from two different filters.

Example : given the lists "A B C D" and "a b c d" I would like to obtain 4 tiddlers where each contains the nth value from both lists:

tiddler1 has var1=A var2=a
tiddler2 has var1=B var2=b
tiddler3 has var1=C var2=c
tiddler4 has var1=D var2=d

This is my attempt:

<$button>

create the tiddlers with parallel filters

<$list filter="[prefix[mytid]]">
  <$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$list>
<$list filter="A B C D" variable="v1">
  <$action-createtiddler $basetitle="mytid" v1=<<v1>> />
</$list>
<$list filter="a b c d" variable="v2">
  <$list filter="[prefix[mytid]!has[v2]]" variable="t">
          <$action-setfield $tiddler=<<t>> v2=<<v2>>/>
  </$list>
</$list>
</$button>

My great hopes for this solution to work turned out to be misplaced ;)

Is there a way to achieve this lind of "parallel matching"?

Thanks in advance!
Erwan

Mark S.

unread,
Dec 26, 2020, 1:34:42 PM12/26/20
to TiddlyWiki
This will do what you want in the most literal fashion:

<$button>alpha mail
<$list filter="[prefix[mytid]]">
  <$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$list>

<$list filter="A B C D" variable="v1">
<$list filter="[<v1>lowercase[]]" variable="v2">
  <$action-createtiddler $basetitle="mytid" v1=<<v1>> v2=<<v2>> />
</$list>
</$list>
</$button>


Mark S.

unread,
Dec 26, 2020, 1:38:43 PM12/26/20
to TiddlyWiki
And here's a version that does it by ordinal position:

<$button>alpha mail
<$list filter="[prefix[mytid]]">
  <$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$list>

<$list filter="[range[4]]" variable="nth">
<$list filter="A B C D +[nth<nth>]" variable="v1">
<$list filter="a b c d +[nth<nth>]" variable="v2">
  <$action-createtiddler $basetitle="mytid" v1=<<v1>> v2=<<v2>> />
</$list>
</$list>
</$list>
</$button>

Erwan

unread,
Dec 26, 2020, 4:08:16 PM12/26/20
to TiddlyWiki
Your second solution is exactly what I need, thank you very much Mark!

Erwan
Reply all
Reply to author
Forward
0 new messages