title: Groovy: the simplest way to detect duplicate, non-consecutive values in a list
body: <p>I know that in Groovy,
  if</p>
  
  <pre><code>list = [1,2,3,1]
  </code></pre>
  
  <p>when</p>
  
  <pre><code>list.unique()
  </code></pre>
  
  <p>with return</p>
  
  <pre><code>[1,2,3]
  </code></pre>
  
  <p>But if I want to detect duplicate value for duplicate, non-consecutive items in a list. How can I do this?</p>
  
  <pre><code>detect([1,2,3,1]) =&gt; true
  detect([1,2,3,2]) =&gt; true
  detect([1,1,2,3]) =&gt; false
  detect([1,2,2,3,3]) =&gt; false
  detect([1,2,3,4]) =&gt; false
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>Edit:
  add these two cases</p>
  
  <pre><code>detect([1,2,2,1]) =&gt; true
  detect([1,2,1,1]) =&gt; true
  </code></pre>
  
  <p>true means any non-consecutive, duplicate occur.</p>