Vala 0.13 was posted on the 17th. Builds on my Fedora 14 with a few warnings, failed 2 tests. I trusted it and sudo make installed. …
Well met,
Vala 0.13 was posted on the 17th. Builds on my Fedora 14 with a few warnings, failed 2 tests. I trusted it and sudo make installed.
Good stuff as usual.
[btiffin@home vala]$ valac randomint.gs
[btiffin@home vala]$ cat randomint.gs
[indent=2]
init
a : int
i : int
runs : int = 50000
range : int = 1001
sum : int = 0
avg : int
// Set a consistent seed
GLib.Random.set_seed(0)
for i = 1 to runs
// return a random value from 1 to range minus 1
a = GLib.Random.int_range(1, range)
print("%d", a)
sum = sum + a
avg = sum / runs
print("%d runs with a range of (%d, %d), a sum of %d and an average of %d", runs, 1, range, sum, avg)
[btiffin@home vala]$ ./randomint | tail -5
522
273
142
81
50000 runs with a range of (1, 1001), a sum of 25048842 and an average of 500
works the charm as expected.
Interfacing the above with OpenCOBOL wouldn't be hard. Just tweak some naming, and get Genie to skip producing a main by having no init paragraph. Then valac -c randomint.gs will produce an OpenCOBOL linkable object file. Or use -C, get c sources, run those through cobc cobol.cob randomint.c … where the … is some tectonic voodoo documented at opencobol article on Genie integration
Cheers,
Brian