0

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?

ARZ
  • 43
  • 7

2 Answers2

0

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

Paulo Moura
  • 18,373
  • 3
  • 23
  • 33
0

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.

jschimpf
  • 4,904
  • 11
  • 24