A Filter Question: Is any item of list one existed in list two?

  1. I have a list of items in a filter called inrecipe-filter, generated from tiddler fields (like apple, banana, raspberry, orange,…) (first list = first array)
  2. I have a dictionary tiddler say fruits, contains key:value pairs (second list = second array)
  3. I want to see if my fruits contains any of the item in the first list (inrecipe-filter)

In brief

<$if filter="fruits contain any item of items" variable=fr>
display the name

Extra info (pseudo code)

<$let  inrecipe-filter="[tag[Singa Salad]]"
          fruits = "[[fruitdict]indexes[]]"
<$list filter=" is any of  inrecipe exist in   fruits" >


You might be able to use the intersection filter run prefix.

@twMat Great solution. But :intersaction is not usable when you have a single list as input just like here:

{{{ [[enlist:raw[a b c a d b e e]] }}}

T+hat,s why I made a (simple) uniq operator that can see which titles are present more than once (please import it from included json) in the code below.

{{{ [[enlist:raw[a b c a d b e e]!uniq[]] }}}

uniq.js.json (1.1 KB)

1 Like

Thank you both!
works great!
In my case intersection works.

The :intersection is really handy here!

I tested using an example like below

<$list filter="[[fruitsdict]indexes[]] :intersection[tag[Singa Salad]fields[]]">

I would add examples to TW-Scripts.

There’s a unique[] operator in TiddlyWiki. What does yours do differently?