variables - Prolog, working with capital letter -
I am working on a database project in SWI-Prolog. The problem is that I work with the names of those players I wanted to read from the input. I need to save my names with capital letters, but interpret them as Chola. Any ideas how to fix this?
I use Since you want to allow a user to enter a name with a letter that is lower or uppercase, I do a case conversion on the code list. I Since you want to store names in a database, I use Here's the code: Usage: Hope it helps! code_type / 2 to ensure that no one The name starts with the capital letter.
read_line_to_codes / 2 I read with
dynamic / 1 to declare that I have some
game name / entries, and I use the
dependent / 1 to add a specific name to the database.
: - Dynamic (play name / 1). - initialization (input) input: - Repeat, format (user_output, 'Please enter a name (or type drop' '): \ n', []), read_line_to_codes (user_input, code1), (atom_codes (left , Code 1) - & gt;!, True (code1, code2) -> atom_codes (name, code2), emphasize (play name (name)), format (current_output, 'playname' Author. \ N ', [name]), failed;). Capital make ([], []) to make capital ([H1 | T], [H2 | T]): - examples of code_type (H2, to_upper (H1))
$ swipl sports_names.pl Please enter a name (or type 'leave'): | . Please enter a name (or type 'leave'): | James Sportsman James wrote to the database. Please enter a name (or type 'leave'): | Susan Sportsman Suzan wrote to the database. Please enter a name (or type 'leave'): |: left? - Game name (X) X = 'John'; X = 'James'; X = 'Susan'
Comments
Post a Comment