[chuck-users] Maybe * 0.7

Tambet qtvali at gmail.com
Tue Aug 24 17:01:08 EDT 2010


http://wiki.cs.princeton.edu/index.php/ChucK/Features/Release - the most
prioritized feat for next release is extending maybe.

As I just thought of it today and my thoughts are better than there - I
think that a simple overload for multiplication operator would be just
enough.

Like this:

if (maybe * 0.2) {
  // Runs with probability of 20%
}

Or, more coherent, but less nice:

if (maybe(0.2)) {
  // Runs with probability of 20%
}

Then, when doing switches, how to handle those? It would be nice to have
something like:

switch {
  case maybe * 0.3:
  case maybe * 0.5:
  case maybe * 0.6:
  case true:
}

In case it would automatically fix all maybes - so that actual probabilities
would add up to 100% and, thus, first one is fixed to about 0.2 and second
one to slightly less than 0.5 ..this would allow really nice play with
probabilities (and, of course, optimizations internally).

Tambet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20100825/21c4ce52/attachment.html>


More information about the chuck-users mailing list