Prolog Question. I need help making this in Prolog . There is a tester at the bo
ID: 3707169 • Letter: P
Question
Prolog Question.
I need help making this in Prolog. There is a tester at the bottom. Any help is appreciated.
Return the number of times that the string "hi" appears anywhere in the given string:
count_hi(String, Count):
-----------------------
Tester
count_hi_test() :-
count_hi("abc hi ho",1),
count_hi("ABChi hi",2),
count_hi("hihi",2),
count_hi("hiHIhi",2),
count_hi("",0),
count_hi("h",0),
count_hi("hi",1),
count_hi("Hi is no HI on ahI",0),
count_hi("hiho not HOHIhi",2).
Explanation / Answer
Write a function which will calculate how many times substrings "hi" is repeated in given string.
simple way is write following code in a function:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.