Understanding list compare


#1

The new list compare with the l modifier is a really cool (and useful :wink:) feature. But there are some quirks here, I still don’t understand.

The TaskPaper User’s Guide says about the list compare:

Both sides of the compare are converted to lists (comma separated) before comparing.

This is the part I don’t understand. If both sides (attribute value and search term) are converted to lists, how do TaskPaper compare them?

Suppose I have an item in the outline containing the tag @value(1,2,3,4,5) and I search for it with

@value =[ln] 1,2,3

will this search match the item or not? And why?


#2

No, for two reasons.

First the l is required to be at the end of the modifier. So you need =[nl] to get rid of the syntax error.

Second the list 1,2,3 doesn’t equal the list 1,2,3,4,5, so the item won’t be matched.

Here are some list compare searches that would match:

@value beginswith[nl] 1,2,3
@value endswith[nl] 5
@value contains[nl] 5,1

Contains is probably the most useful list compare relation. It matches if the searched for list is a subset of the item list being matched against.


#3

Tnanks @jessegrosjean for the prompt answer. Good to know. Unfortunately the User’s Guide says not match about this.

Just curios: How do the other combinations work (<[sl], >[sl], <=[sl], >=[sl], matches[sl], etc.)?


#4

I came up with the following consideration/suggestion for the matches relation:

In case of list compare matches[l] should return matches if the left side is a subset of the right side. For instance the search predicate @value matches[nl] 10,20,22 will then match an item, which has the tag @value(10,22). Other modifier combinations ([il], [sl], and [dl]) should work the same way.

Hope it makes sense.