Reading list from a file -


i don't have experience in prolog.

add(first, second) :-     see('telefon_375319.txt'),     read(l),     seen,     m = [[first, second] | l],     tell('telefon_375319.txt'),     write(m),     nl,     told. 

the purpose of above code to:

  1. read list (which list of list) file (into l).
  2. add list [first, second] @ beginning of list (it might @ end or in middle).
  3. save file.

the result in file following:

[[x, y], end_of_file].

the result should be:

[[x, y], , here should rest of list].

i don't know why ,but prolog read text end_of_file l instead of list stored in file.

what's wrong?

end_of_file not text. it’s atom , it’s read when file ends. in swi prolog see empty line must me placed @ end of file in order read correctly. searching relevant info on that.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -