Search code examples
comparisoncharacterrangeadaletter

Comparing a character to a set of characters in Ada


I'm using Ada and getting and int, and I need to check if it was a character that was converted to an int by converting it back and testing it against a character. The problem is I don't wanna type

if intToChar(popped) = 'a' | 'A' | 'b' | 'B' | (etc.) 
then

I'm new to Ada, so I was wondering if there was an easier way to do this instead of typing out 52 ors. I've tried a few things, but no success.

I was wondering if I could use something like a character range 'a'..'Z' (also, does 'a'..'Z' get the whole alphabet? Or maybe 'A'..'z'?), but I know these are values, not actually characters when used in a type.

I could also make a function to check, but I only need to do this at one spot in the code, so a shortcut I'm missing here would be nice. I could also use a function that checks if a variable is a character, if that is included in Ada.


Solution

  • Found Ada.Characters.Handling.Is_Letter()