Off Topic: Para reirse un rato con Worse Than Faliure

Una de ventanas:

En Oracle Discover:

Otras:

Dejanos tu FeedBack ;)

 

 Y el algoritmo de la semana:

final private static String andvariants[]=
   {"AND", "aND", "AnD", "ANd", "anD", "and", "And", "aNd"};
final private static String notvariants[]=
   {"NOT", "nOT", "NoT", "NOt", "noT", "not", "Not", "nOt"};
final private static String orvariants[]=
   {"OR", "Or", "oR", "or"};


/* Returns the index of the next occurrance of "AND" in 
 * <code>expression</code>starting from <code>begin</code>,
 * without regard to case, or -1 if "AND" cannot be found.
 */
private static int findAnd(String expression, int begin)
{
    boolean found=false;
    int min=expression.length();
       
    for (int i=0; i<andvariants.length; i++)
    {
        if (expression.indexOf(andvariants[ i ], begin)!=-1
            && expression.indexOf(andvariants[ i ], begin)<min)
        {
            found=true;
            min=expression.indexOf(andvariants[ i ], begin);
        }
    }
    return (found ? min : -1);
}

/* Returns the index of the next occurrance of "OR" in 
 * <code>expression</code>starting from <code>begin</code>,
 * without regard to case, or -1 if "OR" cannot be found.
 */
private static int findOr(String expression, int begin)
{
    boolean found=false;
    int min=expression.length();
       
    for (int i=0; i<orvariants.length; i++)
    {
        if (expression.indexOf(orvariants[ i ], begin)!=-1
            && expression.indexOf(orvariants[ i ], begin)<min)
        {
            found=true;
            min=expression.indexOf(orvariants[ i ], begin);
        }
    }
    return (found ? min : -1);
}

/* Returns the index of the next occurrance of "NOT" in 
 * <code>expression</code>starting from <code>begin</code>,
 * without regard to case, or -1 if "NOT" cannot be found.
 */
private static int findNot(String expression, int begin)
{
    boolean found=false;
    int min=expression.length();
       
    for (int i=0; i<notvariants.length; i++)
    {
        if (expression.indexOf(notvariants[ i ], begin)!=-1
            && expression.indexOf(notvariants[ i ], begin)<min)
        {
            found=true;
            min=expression.indexOf(notvariants[ i ], begin);
        }
    }
    return (found ? min : -1);
}

Salu2

Published 12/7/2007 21:00 por Luis Ruiz Pavón
Archivado en:
Comparte este post:
http://geeks.ms/blogs/lruiz/archive/2007/07/12/off-topic-para-reirse-un-rato-con-worse-than-faliure.aspx

Comentarios

# re: Off Topic: Para reirse un rato con Worse Than Faliure

Las ventanas pueden tener su explicación, pero el código...

Y menos mal que no están comparando con "esternocleidomastoideo", que si no, ni un Cray YMP puede...

Cosas vieredes...

Thursday, July 12, 2007 10:21 PM por Rafael Ontivero