Question

There is a big data file whose format is:

111111  11 22 33 44 55 66 77
222222  21 22 23 29 99 98 00
......  ..

then how can i use prolog to calculate each number's frequency ?

Sincerely!

Was it helpful?

Solution

You have two problems: Parsing the file and calculating the frequencies.

For parsing the file, I recommend using library(pio). In that manner you can use s to process the file. So, I'd recommend you learn first about DCGs. They are Prolog's way to describe/generate and parse text. They are even more general than that. But to start with, just see it that way.

This you can then combine with calculating the frequencies. To make this also efficient for very large data see this question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top