Can anyone help me with Prolog ?

[b]every time i run the following code :[/b]
:- use_module(contestlib, [writeN/2]).
cross(N) :-
N1 is N - 1,
B1 is N1 // 2,
Middle is N1 + B1,


  • Please note this is a completely separate question about Prolog programming as I can not figure how to simply start a new post.

    Subject of Post:Help with reading text files using Prolog

    LPA WIN-PROLOG 4.600 - S/N 0014307049 - 05 Sep 2005
    Copyright (c) 2005 Logic Programming Associates Ltd
    Licensed To: Stephen Earl Kirk

    B=64 L=64 R=64 H=256 T=2048 P=8192 S=64 I=256 O=256

    The above is the opening text when executing my LPA Win-Prolog application.


    I first sent this email to LPA Prolog, but have not received any response.

    I have been working for over 25 years with LPA Prolog – I have worked with their MacProlog versions as well as several Win-Prolog versions. I have worked mostly closely with Nicky Johns and some with Brian Steel.

    I have been moderately to severely ill in the last 15 years. However I am back on a Ph.D. track and I desire to use Prolog as the scripting and programming language in my ultimate doctoral dissertation.

    I have a very simple question. I am sure that I have done this Prolog programming before, but at the moment – I have just become overly frustrated by my inability to solve it.

    I will check this forum daily. But if it does not go against Forum Rules (and I cannot imagine why it would. . .). Please also forward your reply posting as an email to my two email addresses as well.

    And also reply back to both of my email addresses as it is very easy for me to miss an important email and to get lost and therefore never be seen due to SPAM. My two best email addresses are:


    Please send a copy of your reply email to both of my e-addresses as SPAM causes me to miss a great amount of emails.

    I would like simply to create a Prolog program, which will read from a text file, each character by character.

    That is it. I feel that I should know this, as I know that I have done this before. But I have some sort of mental block disabling me as to remembering how exactly to do it.

    I am using LPA WIN-PROLOG 4.600. In the below example, I do have the text file:

    My current Prolog script is as follows.
    open('C:\dell\temp.txt', read, In),
    getchar(In, Byte),
    process_stream(Char1, In),

    process_stream(end_of_file, _) :-

    process_stream(Char, In) :-
    getchar(In, Char2),
    process_stream(Char2, In).

    When I execute the script. The output looks like:
    | ?- a.
    ! ----------------------------------------
    ! Error 22 : Instantiation Error
    ! Goal : open('C:\dell\temp.txt',read,_51760)

    It has been a few years, since I have devoted myself to programming in Prolog. But I have done this type of programming before and I cannot comprehend, why I cannot remember how to do it. . . Help, please?

    After a reply posting, please also send your feedback to both of my email address.

    Thank you!
    Take Care and God Bless!
    Stephen Kirk.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion