Reputation: 59
I have been developing expert system as a term project. And in the expert system, I am trying to make a function that will compare two strings including its substring. for example, it will be like:
let's say there's A = 'health_care', B = 'healthy_food'. Because there's a partially matched string, 'health', it will result in 'true'.
I have tried to find some functions related to it, I could not find anything. If you have some ideas or specific solutions, it will be highly appreciated.
Upvotes: 0
Views: 1673
Reputation: 21374
Google: "prolog substring" gives this:
http://www.swi-prolog.org/pldoc/man?predicate=sub_string/5
You can use this to solve your problem like this. Increase the condition on L if you want to only admit longer sub-strings:
sub_string('testing', B, L, A, Sub),
sub_string('tester', B2, L, A2, Sub),
L > 3.
Upvotes: 2