2012-02-01 7 views
13

Sembra che i precedenti sviluppatori del progetto attuale stiano lavorando con il vento battuto che la fine del loro tempo si stesse avvicinando e decidendo creare un codice funzionante ma ingestibile per essere un dolore per chiunque lo affrontasse in seguito. Purtroppo sono detto persona.Sto cercando uno strumento gratuito o add-in, in grado di scomporre le espressioni ternarie

In tutto il codice trovo espressioni ternarie multi-condizionali. Sta diventando un mal di testa da tradurre e riscrivere/refactoring.

Qualcuno sa di uno strumento gratuito, standalone o come componente aggiuntivo per VS 2008, che può scomporre le espressioni ternarie? Non c'è budget per CodeRush su questo progetto. Continuerò a ricodificare se necessario, ma sto cercando di avere un po 'di speranza qui.

Ecco un esempio del problema (mi dispiace di farti dare un'occhiata a questo).

sNoteType = objSelection.Items[1].Selected ? 
    objSelection.Items[0].Selected ? 
    objSelection.Items[3].Selected ? 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "BA " : 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LS " : 
    objSelection.Items[3].Selected ? 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "BA " : 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "FD " : 
    objSelection.Items[0].Selected ? 
    objSelection.Items[3].Selected ? 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "BA " : 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LS " : 
    objSelection.Items[3].Selected ? 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "BA " : 
    objSelection.Items[4].Selected ? 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "LT " : 
    objSelection.Items[5].Selected ? 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty + "EV " : 
    objSelection.Items[2].Selected ? 
    string.Empty + "OV " : 
    string.Empty; 
+8

Ouch. Questo è tutto ciò che ho. Scusate. –

+11

Si consiglia di postarlo su The Daily WTF. –

+0

Sia CodeRush che ReSharper hanno prove gratuite dei propri prodotti che dovrebbero essere abbastanza lunghi per pulire questo codice. Puoi anche giustificare l'acquisto di una licenza per la tua gestione in base alla tua produttività nella pulizia del codice base. – tawman

risposta

5

CodeRush Xpress (gratuito) fa questo e molto altro. Vedi here.

+0

Nella mia nebbia di frustrazione non ho nemmeno visto la versione Xpress sul loro sito. Grazie per avermi indicato qui. –

8

ReSharper può convertire ternario se/else.

L'ho effettivamente eseguito tramite ReSharper e l'output è altrettanto terrificante. Vi auguro buona fortuna per il refactoring.

if (objSelection.Items[1].Selected) 
      if (objSelection.Items[0].Selected) 
       if (objSelection.Items[3].Selected) 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "BA "; 
         } 
        } 
       else 
       { 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LS "; 
         } 
        } 
       } 
      else 
      { 
       if (objSelection.Items[3].Selected) 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "BA "; 
         } 
        } 
       else 
       { 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "FD "; 
         } 
        } 
       } 
      } 
     else 
     { 
      if (objSelection.Items[0].Selected) 
       if (objSelection.Items[3].Selected) 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "BA "; 
         } 
        } 
       else 
       { 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LS "; 
         } 
        } 
       } 
      else 
      { 
       if (objSelection.Items[3].Selected) 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "BA "; 
         } 
        } 
       else 
       { 
        if (objSelection.Items[4].Selected) 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "LT "; 
         } 
        else 
        { 
         if (objSelection.Items[5].Selected) 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty + "EV "; 
         else 
         { 
          if (objSelection.Items[2].Selected) sNoteType = string.Empty + "OV "; 
          else sNoteType = string.Empty; 
         } 
        } 
       } 
      } 
     } 
+0

Grazie per la ricerca. È bene sapere che questa community ha il supporto di utenti come te. Ho intenzione di andare con la versione CodeRush Xpress in modo da non diventare dipendente da uno strumento che non sarò in grado di acquistare in seguito. –

+0

Quel codice mi fa piangere. – Reid

1

Se ho dovuto affrontare una situazione del genere, mi piacerebbe utilizzarlo per indagare Roslyn e vedere come può aiutare. Penso che lo sviluppo di un plugin per VS, il refactoring dell'espressione ternaria che selezioni, si adatterebbe a un progetto "weekend".

http://blog.filipekberg.se/2011/10/23/exploring-how-to-write-a-code-analyzer-with-roslyn/ http://blogs.msdn.com/b/csharpfaq/archive/2011/11/03/using-the-roslyn-syntax-api.aspx

+0

Mi piace il tuo modo di trasformare questo casino in qualcosa di divertente! –

3

ho convertito per voi usando il mio CodeRush Xpress

if (objSelection.Items[1].Selected) 
    if (objSelection.Items[0].Selected) 
     if (objSelection.Items[3].Selected) 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "BA "; 
     else 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LS "; 
    else 
     if (objSelection.Items[3].Selected) 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "BA "; 
     else 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "FD "; 
else 
    if (objSelection.Items[0].Selected) 
     if (objSelection.Items[3].Selected) 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "BA "; 
     else 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LS "; 
    else 
     if (objSelection.Items[3].Selected) 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "BA "; 
     else 
      if (objSelection.Items[4].Selected) 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "LT "; 
      else 
       if (objSelection.Items[5].Selected) 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty + "EV "; 
       else 
        if (objSelection.Items[2].Selected) 
         sNoteType = string.Empty + "OV "; 
        else 
         sNoteType = string.Empty; 

Tuttavia, questo è ancora molto brutto. Vorrei suggerire di utilizzare un tavolo a sei dimensioni verità

string[,,,,,] table = new string[2,2,2,2,2,2]; 
table[0, 0, 0, 0, 0, 0] = "AA"; 
table[0, 0, 0, 0, 0, 1] = "BB"; 
table[0, 0, 0, 0, 1, 0] = "CC"; 
table[0, 0, 0, 0, 1, 1] = "DD"; 
... 

Può quindi essere interrogato come questo

string sNoteType = table[ 
    objSelection.Items[0].Selected ? 1 : 0, 
    objSelection.Items[1].Selected ? 1 : 0, 
    objSelection.Items[2].Selected ? 1 : 0, 
    objSelection.Items[3].Selected ? 1 : 0, 
    objSelection.Items[4].Selected ? 1 : 0, 
    objSelection.Items[5].Selected ? 1 : 0]; 
10

Il significato del codice è in realtà molto più semplice di quanto possa sembrare. Continuando con ReSharper mi ha trovato il seguente:

string sNoteType; 
var items = objSelection.Items; 

var item0Selected = items[0].Selected; 
string item3NotSelectedValue; 
if (items[1].Selected) 
{ 
    item3NotSelectedValue = item0Selected ? "LS " : "FD "; 
} 
else 
{ 
    item3NotSelectedValue = item0Selected ? "LS " : string.Empty; 
} 

if (items[2].Selected) 
{ 
    sNoteType = "OV "; 
} 
else 
{ 
    if (items[5].Selected) 
    { 
     sNoteType = "EV "; 
    } 
    else 
    { 
     if (items[4].Selected) 
     { 
      sNoteType = "LT "; 
     } 
     else 
     { 
      if (items[3].Selected) 
      { 
       sNoteType = "BA "; 
      } 
      else 
      { 
       sNoteType = item3NotSelectedValue; 
      } 
     } 
    } 
} 

Dal Jon ha fatto tutto il lavoro duro, ecco una modifica che penso bolle verso il basso per l'essenza. Ovviamente, vorresti mettere alla prova questo codice al più presto, dato che non riesco a immaginare di non sbagliare nel decodificare questa mostruosità, e il refactoring automatizzato ti porterà solo lontano (non molto, dall'aspetto dei campioni collocati qui):

var items = objSelection.Items; 
string sNoteType = string.Empty;  
if (items[0].Selected && items[1].Selected) { 
    sNoteType = "LS "; 
} else if (items[1].Selected) { 
    sNoteType = "FD "; 
} else if (items[2].Selected) { 
    sNoteType = "OV "; 
} else if (items[3].Selected) { 
    sNoteType = "BA ";  
} else if (items[4].Selected) { 
    sNoteType = "LT "; 
} else if (items[5].Selected) { 
    sNoteType = "EV "; 
} 
5

questo codice dovrebbe comportarsi in modo identico alla mostruosità originale:

string sNoteType; 
if (objSelection.Items[2].Selected) 
{ 
    sNoteType = "OV "; 
} 
else if (objSelection.Items[5].Selected) 
{ 
    sNoteType = "EV "; 
} 
else if (objSelection.Items[4].Selected) 
{ 
    sNoteType = "LT "; 
} 
else if (objSelection.Items[3].Selected) 
{ 
    sNoteType = "BA "; 
} 
else if (objSelection.Items[0].Selected) 
{ 
    sNoteType = "LS "; 
} 
else if (objSelection.Items[1].Selected) 
{ 
    sNoteType = "FD "; 
} 
else 
{ 
    sNoteType = string.Empty; 
} 

per arrivare a questo ho iniziato con il presupposto che tutto ciò che il codice sta facendo è corretto. Ho quindi scritto uno script per generare 64 casi di test, uno per ciascuna combinazione di valori di verità.Immaginate un po 'di questo:

[TestCase("EV ", "000001")] 
[TestCase("LT ", "000010")] 
[TestCase("EV ", "000011")] 
[TestCase("BA ", "000100")] 
[TestCase("EV ", "000101")] 

Poi ho eyeballed gli schemi e ha aggiunto, se-dichiarazioni uno per uno fino a quando il mostro non era più necessario a tutti. Non posso garantire che questo sia il modo in cui l'autore originale stava immaginando la logica, ma io è possibile che garantisca che si comporti in modo identico in tutti i casi possibili.