0
votes

How can use data file with Eclipse-clp or Prolog program. for Variables and Array values. for example if you want to give data to program as an big Array.How can read this data from a data files?

2

2 Answers

0
votes

ECLiPSe includes a CSV library:

http://eclipseclp.org/doc/bips/lib/csv/index.html

This library allows you to parse a CSV file into lists, which you can then convert into an array using another library:

http://eclipseclp.org/doc/bips/lib_public/arrays/index.html

0
votes

If you don't mind having your data in Prolog syntax, it is trivial. Just open a file and use read/2 to read it:

open(File, read, Stream), read(Stream, Data), close(Stream), ...

The file should then contain a single Prolog term, which can be of any valid Prolog type such as structure, list, array, number, string, and arbitrarily nested.