title: Prolog: Checking if the first and last character of a string are left and right squiggly brackets('{' & '}')
body: <p>I am very new to prolog, so assume that I know very little terminology.
  I am using swipl in SWI-prolog.</p>
  
  <p>I want to check if a string starts with a left squiggly bracket('{') and ends with a right squiggly bracket('}'}</p>
  
  <p>Some <a href="https://stackoverflow.com/questions/27707026/find-out-if-first-letter-is-a-vowel-prolog">answers</a> that I have read online have lead me to program the following into my knowledge base to check if the string starts with a left squiggly bracket.</p>
  
  <pre><code>start_left_squiggle([Letter|_]):-
       Letter = '{'.
  </code></pre>
  
  <p>But when I run this function, I get false, when I expect it to return true.</p>
  
  <pre><code>?- start_left_squiggle('{hello').
  false.
  </code></pre>
  
  <p>As well, <a href="https://stackoverflow.com/questions/19734799/getting-last-char-of-a-string-in-prolog">answers</a> that seem correct for checking the if the last character is a squiggly bracket have lead me to code the following.</p>
  
  <pre><code>last_char(str, X):-
      name(S, N), 
      reverse(N, [F|_]),
      name(X, [F]).
  
  end_right_squiggle(Werd):-
      last_char(Werd, Last),
      Last = '}'.
  </code></pre>
  
  <p>And I again get false when running the function, when I expect it to return true.</p>
  
  <pre><code>?- end_right_squiggle('hello}').
  false.
  </code></pre>