Have a list of users. Need to enter a character and find all users whose name starts with this character.
!!! The following tasks embedded predicates conversion symbols and lines are not used.
Have a list of users. Need to enter a character and find all users whose name starts with this character.
!!! The following tasks embedded predicates conversion symbols and lines are not used.
You could do this:
name_starting_with(C, Name) :- % Names that start with C
char_code(C, CC), % Get the character code for C
name([CC|T]), % Query names that start with C (code CC)
atom_codes(Name, [CC|T]). % Convert the found character codes to an atom
On backtrack, this should return each matching name until there aren't any more.
char_code/2 and atom_codes/2 are ISO predicates, but I don't know if Turbo Prolog supports them.