Looking for filter expression (?) that concatenates the contents of a given list of field names and intesects the result with a field from a different tiddler

I am trying to:

  1. concatenate the contents of an arbitrary list of fields for any given tiddler where
  2. use the results to :intersect the contents of the field in a different tiddler

concatenate the three mask fields below
mask1: a b c
mask2: 1 2 3
mask2: zerg cat

concatenatedMask: a b c 1 2 3 zerg cat

target: first a 1 cat blah eek

intersect: “a b c 1 2 3 zerg cat” with a target field “first a 1 cat blah eek”

The result is would be “a 1 cat”

Basically I am using the concatenated mask to select specific content from the target field.

Thanks

Stepway happy to help you but then idea of concatenating multiple fields, also acting as list fields and only then using this for further manipulation or testing seems unnecessarily complex.

  • perhaps if we know the larger problem we can give you a better solution?

Have you tried the filter run prefix intersection?

Something like;

[<concat.list>] :intersection[{!!target}]

Hi Tones:

The first part of the problem is to combine contents of multiple fields into a variable, e.g., concat.list that can then be used in the intersection.

The works if I use literal strings for concat.list and the target list. When I use a function to do the concatenation it fails. What is most confusing is that the two input string look identical.

Thanks
StepWay

Yes, the bigger picture would still help.

However to convert a string containing a list of seperate titles we use one of the enlist operators, or if appropriate split[ ] (contains a space).

  • keep in mind you can concatinate the strings without turning them into titles and do that later.
  • there are whole lot of approaches here, it would take ages to outline them all.

Do contine the conversation as needed.

I am having difficulty in explaining what I am trying to do. This suggests that my approach is probably not well thought out. I will post again once I have a coherent description.

Again - thanks!

I’m not 100% sure, if that’s what you want. Create 2 tiddlers

title: test
target: [[a a]] 2
title: test-intersection
mask-1: 1 2 3
mask-2: [[a a]] b c

\procedure x() test
\procedure source() test-intersection

source fields:

{{{ [<source>fields[]prefix[mask-]] }}}

source mask-* field values:

{{{ [<source>fields[]prefix[mask-]] :map[<source>get<currentTiddler>] +[enlist-input[ ]]  }}}

intersection with test!!target:

{{{ [<source>fields[]prefix[mask-]] :map[<source>get<currentTiddler>] +[enlist-input[ ]] :intersection[<x>get[target]enlist-input[]] }}}

You can use this file for further tests.

test-intersection.json (701 Bytes)

There’s a documentation link to used operators

1 Like

PMario

Your solution was just what I was looking for - thanks!

I created a macro to apply your solution to the general case as follows …

\define intersectMaskWithTargetField(maskFields:"mask-1 mask-2" maskTiddler:"test-intersection" targetTiddler:"test" targetField:"target")

<!-- concatenate maskFields from maskTiddler and
        intersect with targetField from targetTiddler
-->

!!! intersection with test!!target:

{{{ [enlist[$maskFields$]] :map[[$maskTiddler$]get<currentTiddler>] +[enlist-input[ ]] :intersection[[$targetTiddler$]get[$targetField$]enlist-input[]] }}}

\end
<<intersectMaskWithTargetField>>

I forget to add that the json code, breakout of the filter into three parts and links to documentation
in your reply made your solution easy to understand and adapt. Thanks again

1 Like