title: Prolog: How to compose two "functions", to find the min of the squares of my list?
body: <p>I'm learning prolog, and this is the question I have a bit of a problem with right now</p>
  
  <blockquote>
    <p>Write a Prolog function that takes two parameters: an input list, and
    an output variable that is the smallest one among the squares of each
    number in the input list</p>
  </blockquote>
  
  <p>So far I've been able to make a squaring function</p>
  
  <pre><code>square([], []).  
  square([First | Rest], [FirstSquared | SquareRest]) :-
      FirstSquared is First * First,
      square(Rest, SquareRest).
  </code></pre>
  
  <p>But I don't know how to call this new list as a parameter that would look something like this when pseudo-called in SWI-Prolog</p>
  
  <pre><code>min(square[result_List], Answer).
  Answer = *minimum number of list of squares*
  </code></pre>
  
  <p>Or is there an easier way to implement this in Prolog? If you could please explain the logic behind why you do things a certain way in Prolog, that'd be great since I'm more used to coding in C++ and C#. Thanks!</p>