|
Groovy example source code file (random.groovy)
The Groovy random.groovy source code/* The Computer Language Shootout http://shootout.alioth.debian.org/ contributed by Jochen Hinrichsen */ def IM = 139968 def IA = 3877 def IC = 29573 def last = 42D def gen_random(Double max) { last = (last * IA + IC) % IM max * last / IM } def n = (args.length == 0 ? 1 : args[0].toInteger()) - 1 while (n--) { gen_random(100D) } // TODO groovy does not support varargs // def s = new java.io.PrintStream(System.out) // s.printf("%.9f", gen_random(100D)) def nf = java.text.NumberFormat.getInstance() nf.setMaximumFractionDigits(9) nf.setMinimumFractionDigits(9) nf.setGroupingUsed(false) println nf.format(gen_random(100D)) // EOF Other Groovy examples (source code examples)Here is a short list of links related to this Groovy random.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.