Message Boards Message Boards

Web deploying random drumming patterns?

Hello, I've written a short script which will be used to display random drumming patterns I need to practice (which will replace 'test 1' etc). I'd like to deploy this as either a CDF or (preferably) a deployed webpage, so I can just run it whenever I want. I can't seem to find the right combination of form/deploy functions to achieve this - can you help?

And, as a nice touch, I'd like to be able to input the length of practice - currently set to 10 seconds.

tasklist = Dataset[{<|"test 1" -> 1|>,
   <|"test 2" -> 2|>,
   <|"test 3" -> 3|>,
   <|"test 4" -> 4|>,
   <|"test 5" -> 5|>
   }]
For[i = 0, i < 10, i++, AbsoluteTiming[Pause[10]]; 
 Print[i, RandomSample[tasklist, 1]]]

Thanks, Garfield, Chester, UK

3 Replies

Thanks Gareth, That's very useful. After centuries (it seems) as a C/C++ programmer I find WPL a really interesting new landscape for me. I love so many aspects of it, but knocking up simple programs like this still need thinking about. Thanks again, Garfield

Hey. First I recommend you explore the design principles behind the Wolfram Language. Loops and Print statements are examples of procedural programming, which you can do, but the WL is designed around functional programming. Here is an example of functional code that does something like what you want:

tests = {test1, test2, test3};
Dynamic[Refresh[RandomSample[tests, 1][[1]], UpdateInterval -> 10]]

To adjust the update interval, you can place thin inside the Manipulate function:

Manipulate[tests = {test1, test2, test3};
 Dynamic[
  Refresh[RandomSample[tests, 1][[1]], 
   UpdateInterval -> update]], {update, {1, 5, 10, 20}}]

I shall leave it to you to place this inside a CloudDeploy function!

POSTED BY: Gareth Russell

This may be a start:

tasklist = {<|"test 1" -> 1|>, <|"test 2" -> 2|>,
   <|"test 3" -> 3|>, <|"test 4" -> 4|>, <|"test 5" -> 5|>};
 For[i = 0, i < 10, i++, Pause[1];
 Print[{i, RandomChoice[tasklist]}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract