Like a path-segment; touched for the very first time Given an ordered list of 2 or more 2D cartesian points, output a truthy value if either the path touches itself or self-intersects; otherwise output a falsy value if it does not touch itself or self-intersect.
You may assume that consecutive points in the list are distinct.
Examples:
(0,0), (1,0) -&gt; falsey
(0,0), (1,0), (0,0) -&gt; truthy
(0,0), (1,0), (1,1), (0,0) -&gt; truthy
(0,0), (2,0), (1,1), (1,-1) -&gt; truthy
(0,0), (10,0), (0,1), (10,1), (0,2), (10,2) -&gt; falsey

Note all the co-ordinates I gave here are integers.  You may support co-ordinate inputs of whatever you like out of {integer, decimal, rational, floating-point, ...}.  But your implementations calculations must give the correct answers for any inputs given.
Python 2, 315 309 298 382 380 372 bytes



s=sorted
w=lambda(x,y),(X,Y),(z,w):(X-x)*(w-y)-(z-x)*(Y-y)
def I(a,b):p,q=s(a);P,Q=s(b);n,N,m,M=w(p,q,P),w(p,q,Q),w(P,Q,p),w(P,Q,q);return(q&gt;=P)*(Q&gt;=p)if{n,N,m,M}=={0}else(b[1]!=a[0])*(n*N&lt;=0&gt;=m*M)
def f(l):
 i=0
 while i&lt;len(l)-2:
&#9;x=l[i:i+3];i+=1
&#9;if w(*x)==0and s(x)==x:l.pop(i);i-=1
 L=zip(l,l[1:]);return any(I(*l)for l in[(k,x)for i,k in enumerate(L)for x in L[:i]])


Try it online!

Uses the algorithm from here, combined with this SO answer for collinear segments.

Edit: Fixed for line segments continuing in the same direction (eg (0,0),(1,0),(2,0)) by removing the middle point, (resulting in (0,0),(2,0)).