I'm trying to use a piece of software and I'm running into some problems.
It's worth noting that using university computers which have prolog preinstalled(OSX) or Windows computers the same piece of software works. While it does not work on my Linux/Ubuntu machine.
The software starts up with a bash script using this form:
echo "reset_statistics(off), specific_load_predicate(filename), tokenize(\"$2\", List), tex(List, $3)." | ./prolog-executable
The prolog executable is created using swipl -c
and qsave_program/1
Now I found out the predicate tokenize is of the form:
tokenize([A|As], List) :- ...
So it takes a list as input, but the bash script provides a String.
Is it possible using some sort of prolog module or extension that would automatically make the conversion from string to list? Because the same code works on other computers.
double_quotes
tochars
(recommended) orcodes
to turn everything within double quotes into a list of characters or codes. This is how it should have been in the first place, and what also other Prolog systems do. You can also use the command line option--traditional
to get standard-conforming behaviour in this regard. – matalias swipl='/usr/local/bin/swipl --traditional'
, or put:- set_prolog_flag(double_quotes, chars).
in your~/.swiplrc
. Note this all leads to extremely fun situations when your instructor uses a different way to invoke SWI-Prolog. It's almost as if there should be a standard for Prolog! – matERROR: </2: Arithmetic: `'I'/0' is not a function
Could that be caused by a similar prolog flag? – Richard Deurwaarderdouble_quotes
being set tocodes
, you can try that. Note that ideally, library code should be written to work with bothchars
andcodes
! Historically,chars
was the first and preferable option (i.e., double quotes were treated as a list of characters); later, this was changed tocodes
, and I think the long-term best option is to come back again tochars
at last. So, short term, setdouble_quotes
tocodes
in order to work around the SWI 7 problems, and make your future code safe to work withchars
! – mat