title: Checking IP like address list with Prolog
body: <p>I'm trying to build a predicate that given a list (eg. <code>['1', '2', '3', '.', ... , '2']</code>) it has to recognise it as an IP string in the format <code>(NNN.NNN.NNN.NNN)</code> where <code>N</code> is a digit (between <code>0</code> and <code>9</code>) it return true if it is correctly formatted. It must accept also the case where the IP is only (<code>N.N.N.N</code> or <code>NNN.NNN.N.N</code> and other combinations).</p>
  <p>This is what I've done so far</p>
  <pre><code>test([X,Y,Z,D | String]) :- digit(X), digit(Y), digit(Z), dot(D), test(String).
  </code></pre>
  <p>Where digit is a list of facts like <code>digit('0').</code> from <code>0</code> to <code>9</code>; and dot is a fact defined as <code>dot('.')</code>. My code lacks of modularity (it can't recognise single <code>N</code>). Can you help me achieve this?</p>
  <p>Thank you!</p>