Hey all,

While working on my Spaced Repetition/Anki system, I've developed this 
general link-list macro which might be useful. Its purpose is to take a 
subfilter, eg: "tag[Flash Card]", sort them someway, eg: created, an ending 
link (eg: "Results"), and create a series of links from one tiddler to the 
next, all the way to the end. The "next" tiddler in the link is saved in a 
field, whose name you can also specify. 

Right now, it also has the list navigation built in (action-navigate), 
though Im sure we can just add an additional actions parameter to this 
macro in the future.

\define createAndShowLinkedList(subfilter lastlink sortby:created 
<!-- for the n many cards, we return n-1 -->
<$formula-vars counter="count([$subfilter$])-1">
    <!-- iter goes from 0 to n-2  -->
    <$list filter="[range<counter>butlast[]]" variable="iter">
        <!-- arrays need to be accessed from 1 to n -->        
        <$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> + 
1)" next="nth([$subfilter$sort[$sortby$]], <<iter>> + 2)">
            <$action-setfield $tiddler=<<current>> $field=$linkfieldname$ 
            <!--<Current: <<current>>, Next: <<next>> <br/> -->
    <!-- take last element with no forward link -->
    <$list filter="[range<counter>last[]]" variable="iter">
        <$formula-vars current="nth([$subfilter$sort[$sortby$]], <<iter>> + 
            <$action-setfield $tiddler=<<current>> $field=$linkfieldname$ 

<!-- begin list navigation -->
<$list filter="[$subfilter$sort[$sortby$]first[]]">
    <$action-navigate $to=<<currentTiddler>>/>

It currently uses Evan's excellent formula plugin. I'm pretty sure someone 
could do all of the counting, adding, etc without it, but Im not sure how 
to get the *range* using just core features. I was thinking of trying to 
make this my first core PR, but I couldnt see a way around the use of range.

If anyone has any feedback, critcisms, etc please let me know!


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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to