Talk:Pangram checker: Difference between revisions

From Rosetta Code
Content added Content deleted
(proposed cleanup of ActionScript solution)
 
(sure if it's correct)
Line 18: Line 18:
}</lang>
}</lang>
-- [[User:Markjreed|Markjreed]] 20:05, 2 August 2011 (UTC)
-- [[User:Markjreed|Markjreed]] 20:05, 2 August 2011 (UTC)
:Since the current implementation admits being barbaric, why not. --[[User:Ledrug|Ledrug]] 20:16, 2 August 2011 (UTC)

Revision as of 20:16, 2 August 2011

How about this for the same algorithm as the current ActionScript solution, but coded in a saner manner?

<lang ActionScript>function pangram(k:string):Boolean {

 var lowerK:String = k.toLowerCase();
 var has:Object = {}
 
 for (var i:Number=0; i<=k.length-1; i++) {
   has[lowerK.charAt(i)] = true;
 }
 var result:Boolean = true;
 for (var ch:String='a'; ch <= 'z'; ch=String.fromCharCode(ch.charCodeAt(0)+1)) {
     result = result && has[ch]
 }
 return result || false;

}</lang> -- Markjreed 20:05, 2 August 2011 (UTC)

Since the current implementation admits being barbaric, why not. --Ledrug 20:16, 2 August 2011 (UTC)