There’d been some discussions about this before. A straightforward macro like 
this can cause problems if not used carefully.

There are some subtle assumptions that filter execution is deterministic (ie, a 
given filter string will evaluate to the same list every time it is executed in 
the context of the same tiddler store values). For example, the list widget 
re-evaluates the filter each time it is refreshed, and detects changes to the 
list. If there were a randomising filter operator then the filter would be 
deemed to have changed every time, leading to continuous repeated refreshing of 
the list widget content.

Matt Lauber has contributed a shuffle operator that should be more robust, but 
has yet to be finished off:

https://github.com/Jermolene/TiddlyWiki5/pull/3712 
<https://github.com/Jermolene/TiddlyWiki5/pull/3712>

Best wishes

Jeremy



> On 23 Apr 2020, at 15:07, TonyM <[email protected]> wrote:
> 
> Hubert,
> 
> Thanks for sharing !
> 
> Tony
> 
> On Thursday, 23 April 2020 22:24:22 UTC+10, Hubert wrote:
> OK, I've written this quick and dirty one-liner JavaScript macro that takes 
> two arguments: min and max (ideally integers; any floats are floored down on 
> output). Input arguments (min and max) are included in the random output.
> 
> Shorthand syntax below. In this example the macro will output an integer 
> between 10 and 30 (inclusive).
> 
> <<Random 10 30>>
> 
> File attached if anyone finds it useful.
> 
> Regards,
> Hubert
> 
> On Thursday, 23 April 2020 13:11:18 UTC+1, Hubert wrote:
> Hi Tony,
> 
> Also using now to return the milliseconds may be quite helpful
> 
> <<now "0XXX">>
> 
> Wow, that's very creative! Thank you. Through some further tweaking of that 
> we might even be able to define the min and max integers for the random range 
> as well.
> 
> That could be useful - however I thing some of the maths plugins include this 
> eg evans formula plugin.
> 
> Yes, Evan's formula has been my go-to maths plugin for years, also for random.
> 
> Thanks again,
> Hubert
> 
> 
> On Thursday, 23 April 2020 13:06:16 UTC+1, TonyM wrote:
> Hubert,
> 
> That could be useful - however I thing some of the maths plugins include this 
> eg evans formula plugin.
> 
> Also using now to return the milliseconds may be quite helpful
> 
> <<now "0XXX">>
> 
> However just for one shot, not in a list.
> 
> Regards
> Tony
> 
> On Thursday, April 23, 2020 at 9:52:20 PM UTC+10, Hubert wrote:
> Hello,
> 
> It appears that Mathematics Operators 
> <https://tiddlywiki.com/prerelease/static/Mathematics%2520Operators.html> 
> don't currently include a random operator.
> 
> I know this feature can be easily written as a macro with just a few lines of 
> js or, otherwise, the fomula plugin already ships with random out of the box.
> 
> However, I think it would be a great to have the random operator in the core, 
> just like the range <https://tiddlywiki.com/#range%20Operator> operator was 
> added not so long ago.
> 
> Just some thoughts.
> 
> Regards,
> Hubert
> 
> 
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/006916c1-7873-4933-b8ae-715f6259e8a0%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/006916c1-7873-4933-b8ae-715f6259e8a0%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7EED5F4F-F5B5-4647-9B25-A43EBC96E6B2%40gmail.com.

Reply via email to