[tw5] Re: position in a list

2019-08-03 Thread Mohammad
Smart solution Mark!

Added to TW-Scripts.

On Saturday, August 3, 2019 at 12:30:01 AM UTC+4:30, Mark S. wrote:
>
> I think this answers your question as described in your text -- note that 
> it specifies both numbers to compare. It uses pre20
>
> <$vars selected=7 whereami=8>
> <$list filter="[range[1,10]allbeforematch]">
> <>  is before selected item <>
> 
> <$list filter="[range[1,10]allaftermatch]">
> <>  is after selected item <>
> 
> 
>
>
> On Friday, August 2, 2019 at 5:41:33 AM UTC-7, Mohammad wrote:
>>
>> A partial solution
>>
>> <$set name=selected value=7>
>> <$list filter="[range[1,10]]"  variable="item" >
>> <$list filter="[range[1,10]allbefore] +[prefix]">
>> <>  is before selected item: <>
>> 
>> 
>> 
>>
>>
>>
>> This works, any better idea? Any TW intrinsic solution?
>>
>>
>> --Mohammad
>>
>> On Friday, August 2, 2019 at 4:59:10 PM UTC+4:30, Mohammad wrote:
>>>
>>> I have a list of tiddlers, I iterate over the list and I want to know if 
>>> an item is before or after the selected item!
>>>
>>> How to do this?
>>>
>>>
>>> --Mohammad
>>>
>>

-- 
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/41005933-9387-481f-ba29-3c8d67d8b189%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread TonyM
Mohammad,

I would have thought all you need is in the order operators especially
after  find which input 
title follows a specified one 
before  find which input 
title precedes a specified one

https://tiddlywiki.com/?home#Filter%20Operators

I have not used these extensively yet but I believe they hold the key to 
problems like your own, keep in mind you can use these to establish one 
set, and subtract that from another set. These should provide all the 
elements for lists, queues head and tail operations and alot more.

For example
using first then storing rest, then using first on the rest allows you to 
step through every member and allows you to see what is coming. You could 
count how many items remain in rest for a progress indicator and more

Also
The range operator documentation should also be extended to show how to 
provide values to the ,, parameters from fields and 
variables.
<$set name=number-or-members value={{{ [filter] +count[]] }}}>
the range[1,number-or-members]

Second section in table is Order Operators, note that N is a number you can 
provide.

after  find which input 
title follows a specified one 
before  find which input 
title precedes a specified one 
bf  same as rest 
 
butfirst  same as rest 
 
butlast  discard the last N 
input 
titles 
first  select the first N input 
titles 
last  select the last N input 
titles 
limit  select the first or 
last N input titles ✓ !
next  find which titles in a 
list field follow the input ones 
nsort  sort the input by 
number field !
nsortcs  sort the input 
titles by number field, treating upper and lower case as different !
nth  select the Nth input title 
order  selectively reverse 
the input list ✓ 
previous  find which 
titles in a list field precede the input ones 
rest  discard the first N input 
titles 
reverse  reverse the order 
of the input titles 
sort  sort the input by text 
field ✓ !
sortan  sort the input by 
text field considering them as alphanumerics ✓ !
sortcs  sort the input by 
text field, treating upper and lower case as different
Regards
Tony

On Friday, August 2, 2019 at 10:29:10 PM UTC+10, Mohammad wrote:
>
> I have a list of tiddlers, I iterate over the list and I want to know if 
> an item is before or after the selected item!
>
> How to do this?
>
>
> --Mohammad
>

-- 
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/a2f3c089-a08d-40ca-8d21-4d45b2d88515%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread 'Mark S.' via TiddlyWiki
I think this answers your question as described in your text -- note that 
it specifies both numbers to compare. It uses pre20

<$vars selected=7 whereami=8>
<$list filter="[range[1,10]allbeforematch]">
<>  is before selected item <>

<$list filter="[range[1,10]allaftermatch]">
<>  is after selected item <>




On Friday, August 2, 2019 at 5:41:33 AM UTC-7, Mohammad wrote:
>
> A partial solution
>
> <$set name=selected value=7>
> <$list filter="[range[1,10]]"  variable="item" >
> <$list filter="[range[1,10]allbefore] +[prefix]">
> <>  is before selected item: <>
> 
> 
> 
>
>
>
> This works, any better idea? Any TW intrinsic solution?
>
>
> --Mohammad
>
> On Friday, August 2, 2019 at 4:59:10 PM UTC+4:30, Mohammad wrote:
>>
>> I have a list of tiddlers, I iterate over the list and I want to know if 
>> an item is before or after the selected item!
>>
>> How to do this?
>>
>>
>> --Mohammad
>>
>

-- 
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/23269a20-7d24-4ad1-8f77-9081ccf068bb%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread 'Mark S.' via TiddlyWiki
<$set name=selected value=7>
<$list filter="[range[1,10]]"  variable="item" >
<$list filter="[range[1,10]allbefore] 
-[range[1,10]allbefore] -[range[1,10]allafter]">
<>  is before selected item: <>




On Friday, August 2, 2019 at 5:41:33 AM UTC-7, Mohammad wrote:
>
> A partial solution
>
> <$set name=selected value=7>
> <$list filter="[range[1,10]]"  variable="item" >
> <$list filter="[range[1,10]allbefore] +[prefix]">
> <>  is before selected item: <>
> 
> 
> 
>
>
>
> This works, any better idea? Any TW intrinsic solution?
>
>
> --Mohammad
>
> On Friday, August 2, 2019 at 4:59:10 PM UTC+4:30, Mohammad wrote:
>>
>> I have a list of tiddlers, I iterate over the list and I want to know if 
>> an item is before or after the selected item!
>>
>> How to do this?
>>
>>
>> --Mohammad
>>
>

-- 
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/7aaf65c3-440c-40f5-9dab-8d56f8c8a440%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread TonyM
Mohammad

This is not the full answer but counting the items in a list can give you 
helpful information. The set widgets select parameter and the rest operator 
amongst others all provide the components to do this and do it well.

Perhaps store the number of items from count then use the select parameter to 
iterate each item. The position in the list will then be a number and last time 
I looked 4 was after 3, and 3 before 4 so the relation ship is obviouse

Tony

-- 
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/c4181f82-4ba0-40ab-9349-e548a880b343%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread Mat
Maybe you can treat the list like a string and cut the list at the selected 
item (listbefore[]) and then see if the item is in the remaining list - if 
it is not, then it was before otherwise it was after.

<:-)

-- 
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/e7908463-6325-4f7d-b6fc-8a5506f14efb%40googlegroups.com.


[tw5] Re: position in a list

2019-08-02 Thread Mohammad
A partial solution

<$set name=selected value=7>
<$list filter="[range[1,10]]"  variable="item" >
<$list filter="[range[1,10]allbefore] +[prefix]">
<>  is before selected item: <>






This works, any better idea? Any TW intrinsic solution?


--Mohammad

On Friday, August 2, 2019 at 4:59:10 PM UTC+4:30, Mohammad wrote:
>
> I have a list of tiddlers, I iterate over the list and I want to know if 
> an item is before or after the selected item!
>
> How to do this?
>
>
> --Mohammad
>

-- 
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/f72e4878-f7a2-4184-b3b9-366ed324eae5%40googlegroups.com.