Input would be a text file
word1,word2,word3 etc
or
word1
word2
word3
etc.
End product would be
Code: Select all
Wordlist = [Word1,Word2,Word3...]
Code: Select all
Wordlist = [Word1,Word2,Word3...]
Code: Select all
one,two,three,four,five,
six,seven,eight,nine
Code: Select all
class predicates
fileToList : (string FileName, string Separator) -> string_list StringList.
clauses
fileToList(FileName, Separator) = StringList :-
FileAsString = file::readString(FileName),
StringList = string::split(FileAsString, Separator).
clauses
run() :-
SSnl = fileToList("WordsAcross.txt", "\n"),
stdio::write("\nString per line:\n", SSnl, "\n"),
%
SScomma = fileToList("WordsAcross.txt", ","),
stdio::write("\nComma-separated:\n", SScomma),
_ = stdio::readLine().
Code: Select all
class predicates
fileToList2 : (string FileName, string PrefixWanted) -> string_list StringList.
clauses
fileToList2(FileName, PrefixWanted) = StringList :-
Input = inputStream_file::openFileBom(FileName),
StringList =
[ S ||
Input:repeatToEndOfStream(),
S = Input:readLine(),
string::hasPrefix(S, PrefixWanted)
],
Input:close().