Another way to look at it ;  
Butlast purpose discard the last N input title(s)

So saying  "discard the last 0 input titles" is non sensical 
If you actually want to discard 3, then 2 then 1 perhaps you filter needs 
find another way once it reaches 0

Tones
On Monday, 28 June 2021 at 13:07:37 UTC+10 History Buff wrote:

> Thanks Eric,
>
> I appreciate that. I looked at it, but I really don’t know JavaScript. 
> Makes me want to learn though. 
>
>
>
> On Sun, Jun 27, 2021 at 12:07 PM Eric Shulman <elsd...@gmail.com> wrote:
>
>> On Sunday, June 27, 2021 at 11:28:50 AM UTC-7 History Buff wrote:
>>
>>> I don't understand why a 0 in the butlast operator would yield no results
>>>
>>
>> The butlast[] operator is defined in this shadow tiddler:
>> https://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Ffilters%2Flistops.js
>>
>> Here's the javascript code from that tiddler:
>> exports.butlast = function(source,operator,options) {
>> var count = $tw.utils.getInt(operator.operand,1),
>> results = [];
>> source(function(tiddler,title) {
>> results.push(title);
>> });
>> return results.slice(0,-count);
>> };
>>
>> The first line gets the operand value, defaulting to 1.
>> The next 4 lines copy the entire list of items into a results array
>> The last line uses the javascript slice() function to remove items from 
>> the results array and then return that array
>>
>> Here's the documentation for the javascript slice() function:
>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
>>
>> Note the description of the "end" parameter:
>> Zero-based index before which to end extraction. slice extracts up to *but 
>> not including* end.
>>
>> Thus, when you used butlast[0], the filter code invokes slice(0,-0),
>> i.e., "*starting from the first item up to but not including the first 
>> item*"
>> which results in *no items* being returned.
>>
>> enjoy,
>> -e
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "TiddlyWiki" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/tiddlywiki/lROJc--2xFI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> tiddlywiki+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/c1f40a73-746d-4c39-89b9-6786c9caee0fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/tiddlywiki/c1f40a73-746d-4c39-89b9-6786c9caee0fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/faaa280d-a866-47d3-abef-5ec8e51e5d5dn%40googlegroups.com.

Reply via email to