我通过以下代码将 X = [[1,2,3,4,5,6],[6,5,4,3,2,1]|...] 写入文件:
?-tell('test.txt'),maplist(format('~d ~d ~d ~d ~d ~d ~n'),X),told.
$cat test.txt
1 2 3 4 5 6
6 5 4 3 1 1
...
并使用以下代码恢复它:
?-open("test.txt",read,F),read_stream_to_codes(F,N),write(N),close(F).
N = [49, 50, 51, 52, 53, 54 ...]
将 N 转换为 [[1,2,3,4,5,6],[6,5,4,3,2,1]...] 的最佳方法是什么?
真挚地!