Prev: debt consolidation services debt consolidation debt wyoming student loan debt consolidation
Next: Online brand Carisoprodol order Carisoprodol online cod brand Carisoprodol Now
From: Johannes Baagoe on 10 Apr 2010 20:24 Johannes Baagoe : > (I intend to post the corrected version with a lot of context under the > heading "Random musings" on a website. I shall drop a line to the group > when it is done - some things concern javascript specifically, although > the theme is more general.) Here it is: http://baagoe.com/en/RandomMusings/javascript/ Or rather, that is a first version of the part that is of special relevance to javascript, with links to code. Feedback would be much appreciated, especially about the common interface to all the generators. Does it meet the needs? Would it be worth the trouble to provide means to get and set the internal state, instead or in addition to the seeding mechanisms and the `args` property? I have so far been in favour of keeping things simple, but if enough people want more features, I may reconsider. -- Johannes
From: Hans-Georg Michna on 11 Apr 2010 05:59 On Sat, 10 Apr 2010 19:24:08 -0500, Johannes Baagoe wrote: >Johannes Baagoe : >> (I intend to post the corrected version with a lot of context under the >> heading "Random musings" on a website. I shall drop a line to the group >> when it is done - some things concern javascript specifically, although >> the theme is more general.) >Here it is: http://baagoe.com/en/RandomMusings/javascript/ > >Or rather, that is a first version of the part that is of special >relevance to javascript, with links to code. > >Feedback would be much appreciated, especially about the common interface >to all the generators. Does it meet the needs? Would it be worth the >trouble to provide means to get and set the internal state, instead or in >addition to the seeding mechanisms and the `args` property? > >I have so far been in favour of keeping things simple, but if enough >people want more features, I may reconsider. Thanks! Good to have random number generators within reach, even if I don't need one right now. But I know that perhaps every other year I need one. Hans-Georg
From: Scott Sauyet on 11 Apr 2010 15:06 Hans-Georg Michna wrote: > Johannes Baagoe wrote: >> Here it is:http://baagoe.com/en/RandomMusings/javascript/ > Thanks! Good to have random number generators within reach, even > if I don't need one right now. But I know that perhaps every > other year I need one. I seem to need them about twice as frequently. So I guess I owe about twice the thanks! ::-) These look great, to my untutored eyes. -- Scott
From: Johannes Baagoe on 12 Apr 2010 11:40 Scott Sauyet : > Hans-Georg Michna : >> Johannes Baagoe : >>> Here it is:http://baagoe.com/en/RandomMusings/javascript/ >> Thanks! Good to have random number generators within reach, even >> if I don't need one right now. But I know that perhaps every other >> year I need one. > I seem to need them about twice as frequently. So I guess I owe > about twice the thanks! ::-) > These look great, to my untutored eyes. Don't mention - it is nice to see that one has satisfied a genuine demand, rather that spent a lot of time with a great solution to a non-problem ;) Seriously, I quite understand that my use of javascript is somewhat eccentric. Still, comp.lang.javascript is supposed to be about the computer language javascript, and if I do not find the answers to my questions here, I do no know where else to go. So please bear up with my peculiarity... I would really appreciate comments on the way I have programmed the PRNGs, not from the point of view of PRNG algorithms unless someone happens to be more of an expert than myself, but from the point of experts in javascript, which I most definitely am not. My RandomXXX functions are quite different from ordinary constructors, in fact, they are not constructors at all. I leave `this` alone, and simply return a Function to which, since it is also an Object, I have added some properties and methods. From what I understand, that is a bit like putting ice cubes in your cognac: there is no law against it, but it raises eyebrows. But it allows me to do things I want, e.g. (`new` being in effect a NOP): var randInt = new RandomMWC4('Timbuktu').uint32; randInt(); // returns a random positive integer less than 2^32: 252468640 With a proper constructor, I would have had to write var rand = new RandomMWC4('Timbuktu'); rand.uint32(); // returns 252468640 Which works, too - but you do not *have* to do it, you can directly assign the method you want to a variable and be done with it. So, my question is: what are the problems with that approach? -- Johannes
From: Scott Sauyet on 12 Apr 2010 12:28
Johannes Baagoe wrote: [ regarding http://baagoe.com/en/RandomMusings/javascript/ ] > I quite understand that my use of javascript is somewhat eccentric. I don't think so. You're simply taking advantage of one of the nicer features of the language. The only thing that seems odd to me is to use the initial capital letter for the function name. By convention, that is reserved for constructor functions. Although "new RandomXXX()" is legal, it is not helpful, and it is slightly wasteful since the newly created object is discarded immediately. But as presumably there should not be many of these created, it doesn't seem a significant issue. If you did expect a large number of these to be created, then you might want to think about having a proper constructor and having the ancillary functions as properties of its prototype. Otherwise, I think you're fine. -- Scott |