New Feature PR: shuffle[] filter operator for deterministically randomizing list orders

78 views
Skip to first unread message

Matthew Lauber

unread,
Jan 19, 2019, 11:21:50 PM1/19/19
to TiddlyWikiDev
All, 
   I've opened a Pull Request for feedback for a filter operator that I think could be useful in a variety of situations.  This is a "shuffle" operator.  It takes as a optional parameter a "seed" value, and based on that value, randomizes the list.  So, every time you shuffle with the seed "test" you'll get the list back in the same random order, but if you then seed with "apple", you've get a different order.  If you don't provide a seed, you'll get a new order every time it's rendered.  

With this filter operator it's possible to:
  • Display a list in a random order via "shuffle[]"
  • Display the list in an order that changes when you press a button, via "shuffle{state tiddler}"
  • Select a random subset of tiddlers from a list via "shuffle[]first[N]"
  • Select a random subset of tiddlers from a list that changes when you press a button, via "shuffle{state tiddler}first[N]"
I think this is a pretty basic tool that allows users to invent a variety of solutions on top of it, and I think it would be useful.  I'd like to hear feedback on whether people think it's worth putting in the core, or if it should stay as plugin.  (It's available at present from my plugin library at https://mklauber.github.io/tw5-plugins)

Matt Lauber

Mohammad Rahmani

unread,
Jan 20, 2019, 1:05:14 PM1/20/19
to TiddlyWikiDev
Matt,
 Good job, thank you!
One question: in TW-Scripts, I like whenever I visit the page a random tiddler be shown. Can shuffle operator do that?
I was trying to use Tobias Beer macro: https://tobibeer.github.io/tb5/#Tagline%20Macro

--Mohammad

TonyM

unread,
Jan 20, 2019, 11:09:31 PM1/20/19
to TiddlyWikiDev
Matt,

I think such a filter operator would naturally be in the core given similar support in most languages, and tiddlywiki uses filters to operate its fundamental logic.

However this can be dependant on the level of "bloat" to the core. If it requires a lot of bytes to implement it should be left out and placed in a plugin, perhaps in the tiddlywiki plugin library but documented on tiddlywiki.com. It is traditional to present a plugin first, unless you can persuade the "developers" over in GitHub or here to include it in the core.

I expect a lot of people would not use this feature, but I can see why it would be valuable to some. Text based games, Flash card study notes, randomised questions, random stories, daily message, random post etc... 

Regards
Tony

Matthew Lauber

unread,
Jan 21, 2019, 12:02:13 AM1/21/19
to TiddlyWikiDev
Yes, this would be an excellent use for it.  In the settings -> Default Tiddlers box, you can put something like `[shuffle[]first[N]]` and you'll get N random tiddlers from the list of all tiddlers.  To be more specific, just pass in the input list you want to select from, e.g. `[tag[TAG]shuffle[]first[N]]`

@TiddlyTweeter

unread,
Jan 21, 2019, 12:57:10 PM1/21/19
to TiddlyWikiDev
Ciao Matt,

It think it is a neat tool with good potential usage. I think it should be a plugin. Not in the core. Mainly because most users are unlikely to need it.

My two cents
Josiah

Diego Mesa

unread,
Jan 22, 2019, 7:58:38 AM1/22/19
to TiddlyWikiDev
Hey Matt,

Just to voice my opinion, I think it should be part of the core. This could be a great, easy, built-in way to encourage a "Random" option for the story river, sidebar, etc. just like wikipedia's 


Diego

Mohammad Rahmani

unread,
Jan 22, 2019, 9:07:04 AM1/22/19
to TiddlyWikiDev
Thanks Matt,
 That is really amazing!

Cheers
Mohammad
Reply all
Reply to author
Forward
0 new messages