Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Thank you Patrick,but it kinda difficult for me to understand your code as I am new to prolog.Can you help me with my approach. I was thinking to convert each line into lists(I don't know how)and then use this [_ , _ , _ , X|tail]to get 4th word.Can you tell me how to convert each line to list and whether my approach is good? Commented Sep 23, 2014 at 6:09
  • 2
    @noobcoder: yes, you can use [_,_,_,Word|_] = ListOfWords to pick out the 4th element from a list. Commented Sep 23, 2014 at 9:20
  • @noobcoder: If you want to use built-in predicates, look at jschimpf's answer. I'll expand this a bit to make it more clear. Commented Sep 23, 2014 at 13:25