?-g("Two funny little red apples fell from a tree one day").
#VISUAL PROLOG 5.2 KEY CODE#
s(_,B):-įinally: Putting the code together: g(B):-Įxample: ?-g("A dog and an apple and a pipe"). So now we use a predicate that simply prints the list of words that have doubles ignoring those words with no doubles i.e. checkdouble(,):-!.įourth: By this point you will have a number of list: empty and those containing duplicates from each word. If yes then load the character in List R. The checkdouble second predicate checks if a character is in the remaining list (using member). the base case predicate tell to stop when get empty brackets. Third: Then check each list if it contains doubles. Second: In the second predicate, we split each word into a separate list of characters. I have used the built-in function split_string.Example: "The dog" will become "The","dog". I've written my code using basic prolog:įirst: The first predicate separates the sentence into words. I tried computing this prolog task, maybe you may find something useful in my solution that may help you with yours. This flow pattern doesn't exist openread(o,i) Write_symbols():-write(H),write_symbols(T). For example from text: A dog and an apple and a pipe. I need to write prolog predicate that reads file and creates a list of words with repeating symbols.