If you're trying to return the status (state) of a pin, that is simpler even:
for (x=0; x<54; x=x+1){
Serial.print ("D");
Serial.print (x);
Serial print (" is ");
Serial.println (digitalRead(x));
}
for (x=0; x<16; x=x+1){
Serial.print ("A");
Serial.print (x);
Serial print (" is ");
Serial.print (analogRead(x));
Serial.print ("( may be used as D)");
Serial;println (x+54);
}
Digital pins will return 0 or 1.
Analog pins will read close to 0 and 1023 when connected to digital things, and 0 to 1023 when connected to analog things.
Any user can look at the results and determine if he has an analog or digital input. If digital, then code to use digitalRead instead of analogRead.