Note that there are some explanatory texts on larger screens.

plurals
  1. POError using string_to_atom: Arguments are not sufficiently instantiated
    primarykey
    data
    text
    <p>I'm working on a URI parser in Prolog, but at the moment I'm stuck with something much simpler. I am exploring a string to find a particular char, ":", and when I find it, I want to have a string that only contains the concatenated chars before it.</p> <p>This program:</p> <pre><code>% caratteri speciali colonCheck(S) :- string_to_atom([S], C), C = ':'. % S==: headGetter([H|T], [H]) :- !. % struttura uri uri(Scheme, Userinfo, Host, Port, Path, Query, Fragment). % parsing uri parsed_uri(UriInput, uri(Scheme,Userinfo,Host,Port,Path,Query,Fragment)) :- scheme(UriInput, uri(S,Userinfo,Host,Port,Path,Query,Fragment)), not(headGetter(UriInput, ':')), !, string_to_atom([S], Scheme). % controllo Scheme, in ingresso ho i dati da controllare e l'oggetto uri che % mi servirà per inviarlo al passaggio successivo ho trovato i due punti scheme([H|T], uri(Scheme,Userinfo,Host,Port,Path,Query,Fragment)):- colonCheck(H), !, end(Scheme). % non trovo i due punti e procedo a controllare il prossimo carattere % (la testa dell'attuale coda) scheme([H|T], uri(Scheme,Userinfo,Host,Port,Path,Query,Fragment)):- not(colonCheck(H)), scheme(T, uri(This, Userinfo,Host,Port,Path,Query,Fragment)), append([H], This, Scheme). %fine computazione end([S]). </code></pre> <p>Gives this result:</p> <pre><code>?- scheme("http:", uri(A,_,_,_,_,_,_)). A = [104, 116, 116, 112, _G1205]. </code></pre> <p>I think that part is correct, but now I want to convert the char list into a string, so I changed the last line to this:</p> <pre><code>end([S]) :- string_to_atom([S], K). </code></pre> <p>But I get this error message:</p> <blockquote> <p>ERROR: string_to_atom/2: Arguments are not sufficiently instantiated</p> </blockquote> <p>I'm probably missing something. Can you tell what it is?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload