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 code_type / 2 to ensure that no one The name starts with the capital letter.

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 read_line_to_codes / 2 I read with

Since you want to store names in a database, I use 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.

Here's the code:

 : - 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))   

Usage:

  $ 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'   

Hope it helps!

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -