[tw5] Re: is it possible to list fields that have a specific prefix ?

How about listing fields whose value has a specific prefix?

Right now I have a list filter that looks like this:

<$list filter="[field:year[1980]] [field:year[1981]] [field:year[1982]] [field:year[1983]] [field:year[1984]] [field:year[1985]] [field:year[1986]] [field:year[1987]] [field:year[1988]] [field:year[1989]] +[tag[Song]get[title]sort[title]]">

It would be so much nicer if I could do something like:

<$list filter="[field:year][prefix[198]][tag[Song]get[title]sort[title]]">

I’ll even take any suggestion that lets me use a list or range of years instead of having to specify each one with its own [field:year[]] wrapper.

Thanks,
Todd

Try this:

<$list filter="[tag[Song]sort[]] :filter[get[year]prefix[198]]">

</$list>

Works perfectly!

Thanks, Eric. I knew there had to be a way to make it more concise.

Eric Shulman wrote:

<$list filter="[tag[Song]sort[]] :filter[get[year]prefix[198]]">

</$list>

I’m just curious if this would be more efficient:

<$list filter="[tag[Song]] :filter[get[year]prefix[198]] +[sort[]]">

</list>

and if it’s enough so that it’s even worth considering. The point is that sorting is at best
O(n log(n)), and filtering should be linear, so if we filter to reduce the list first, we should

have a faster sort call. Or am I missing something about how filters operate?

(@EricShulman: Thanks for the edit. I didn’t realize this was editable when posted on Google Groups. I also have no idea why it cut off the first line of quoted code, which is there in GG. Odd.)

@Scott_Sauyet, you are correct. Placing +[sort[]] after the :filter[...] run would be more efficient, especially if there are a lot of tiddlers that match [tag[Song]] but only a few that have a year field that begins with “198”, since the sort operator would be applied to the smallest number of items.