|
-
Feb 27th, 2005, 01:33 PM
#1
[Prolog] How to find a word in a string
Given an input in a string. Something like:
Code:
eliza :-
write('Hello'),nl,
read(sInput).
How can I find out if a certian word is in the sInput variable. So I can give feedback?
ØØ
Last edited by NoteMe; Feb 28th, 2005 at 11:37 AM.
-
Feb 28th, 2005, 10:11 AM
#2
Fanatic Member
Re: [Prolog] How to find a word in a string
Huh?
VB6.0 has an instr function.
If this is another language, perhaps the specific-language forum would be a better place.
or is it language-specific?
-
Feb 28th, 2005, 10:15 AM
#3
Re: [Prolog] How to find a word in a string
 Originally Posted by JPicasso
Huh?
VB6.0 has an instr function.
If this is another language, perhaps the specific-language forum would be a better place.
or is it language-specific?
Hehehe...you are so cute... ...I added the language in [ ], Prolog it is called, and it looks nothing like VB...
Kedaman helped me on MSN. Here is the solution:
Code:
%example on how to run (at the moment..:))
%atom_chars('you are an idiot',A),atom_chars('an',B),search(A,B,C).
search2([_|_],[],1).
search2([X|XS],[X|YS],N):- search2(XS,YS,N).
search([X|XS],[X|YS],N):- search2(XS,YS,N).
search([_|XS],YS,N):- search(XS,YS,N1),N is N1+1.
search([],_,0):-!,fail.
-
Mar 2nd, 2005, 03:06 PM
#4
Fanatic Member
Re: [Prolog] How to find a word in a string
 Originally Posted by NoteMe
Hehehe...you are so cute...  ...
yeah, I get that a lot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|