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:
- read list (which list of list) file (into l).
- add list [first, second] @ beginning of list (it might @ end or in middle).
- 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
Post a Comment