Re: [flexcoders] Generating Random key

2009-01-06 Thread Manish Jethani
On Tue, Jan 6, 2009 at 7:42 AM, Josh McDonald dzn...@gmail.com wrote: A quick take on it: Trying to improve on some already neat code... function randomLetter() : String { const noVowels : String = BCDFGHJKLMNPQRSTVWXYZ;

Re: [flexcoders] Generating Random key

2009-01-06 Thread Josh McDonald
That's better (also cleaner and faster). I just don't trust IEEE floats :) -Josh On Wed, Jan 7, 2009 at 4:05 AM, Manish Jethani manish.jeth...@gmail.comwrote: On Tue, Jan 6, 2009 at 7:42 AM, Josh McDonald dzn...@gmail.com wrote: A quick take on it: Trying to improve on some already neat

Re: [flexcoders] Generating Random key

2009-01-05 Thread Brendan Meutzner
I'm sure someone will inevitably suggest a better method, but the following would do the trick: 1) Create UID with UIDUtil.createUID() 2) Strip '-' symbols / Strip vowels 3) Truncate to 12 characters (if there weren't enough after stripping vowels, just repeat steps 1 and 2 and append to current

RE: [flexcoders] Generating Random key

2009-01-05 Thread Tracy Spratt
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Brendan Meutzner Sent: Monday, January 05, 2009 5:25 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Generating Random key I'm sure someone will inevitably suggest a better method

RE: [flexcoders] Generating Random key

2009-01-05 Thread Alex Harui
Or look at mx.utils.UIDUtil. From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Tracy Spratt Sent: Monday, January 05, 2009 2:46 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Generating Random key Yeah, to get that specific format, you will need

Re: [flexcoders] Generating Random key

2009-01-05 Thread anuj sharma
Awesome guys your guidance help me in achieving this withing 30 minutes, it is working now Thanks for your help again Anuj On Mon, Jan 5, 2009 at 2:19 PM, anuj181 anuj...@gmail.com wrote: Hi I need to work on a piece of code in which whenever user clicks on the button , the code should

Re: [flexcoders] Generating Random key

2009-01-05 Thread Brendan Meutzner
So what did you end up putting together? Should post the code here for the next guy... Brendan On Mon, Jan 5, 2009 at 5:41 PM, anuj sharma anuj...@gmail.com wrote: Awesome guys your guidance help me in achieving this withing 30 minutes, it is working now Thanks for your help again Anuj

Re: [flexcoders] Generating Random key

2009-01-05 Thread anuj sharma
Hi Brendan makes sense to put the code :-), With the format I was looking for following code works perfectly for me, I am not sure thats the right way of coding but this is working for my purpose. I am pretty sure there can be far far better way for this Anuj

Re: [flexcoders] Generating Random key

2009-01-05 Thread Josh McDonald
A quick take on it: function randomLetter() : String { const noVowels : String = BCDFGHJKLMNPQRSTVWXYZ; return noVowels.charAt(Math.round(Math.random() * (noVowels.length - 1))); } function

Re: [flexcoders] Generating Random key

2009-01-05 Thread Doug McCune
Heh, but if you're REALLY going for unreadable lines of code, you might as well go all the way: function repeat(n:Number, f:Function) : Array { return n 1 ? repeat(n-1, f).concat(f()) : [f()]; } function createUID():String { return repeat(4, function(){ return repeat(3, function(){ return

Re: [flexcoders] Generating Random key

2009-01-05 Thread Josh McDonald
Stupid ECMAScript... It'd be much more readable in Ruby/Lisp/Ioke/etc :) On Tue, Jan 6, 2009 at 12:38 PM, Doug McCune d...@dougmccune.com wrote: Heh, but if you're REALLY going for unreadable lines of code, you might as well go all the way: function repeat(n:Number, f:Function) : Array {

Re: [flexcoders] Generating Random key

2009-01-05 Thread Josh McDonald
...Although some features from JS1.7 / 1.8 would be a big step in the right direction. On Tue, Jan 6, 2009 at 12:48 PM, Josh McDonald dzn...@gmail.com wrote: Stupid ECMAScript... It'd be much more readable in Ruby/Lisp/Ioke/etc :) -- Therefore, send not to know For whom the bell tolls.

Re: [flexcoders] Generating Random key

2009-01-05 Thread Alan Klement
What makes me cringe is the anonymous function there, the tertiary expressions, and inline typing and instantiating. Variables get moved to the top of the function anyway - so why give your self the headache of creating them inline. 4-5 extra lines wont kill ya will it? On Jan 5, 2009,

Re: [flexcoders] Generating Random key

2009-01-05 Thread Josh McDonald
Not at all :) I just like functional programming style, and in my case I have a version of times(n,f) in a util class. The version I posted above is actually no good on AVM2 due to the lack of tail-calls. A longer but clearer, more flexible (and iterative, hence stack-safe) version I actually use