I want to make a module in Mathematica that return true if the first list (L1) is in the second list (L2) assuming that the length of L2 is greater than the length of L1. I did it in this way, the problem is that always return False and I don't know why. EDIT: I have solved a problem: I wrote "if" instead of "If". Now I get an infinitely loop.
isSegment[L1_List, L2_List] := Module[{i, j}, For[i = 1, i + Length[L1] - 1 <= Length[L2],
For[j = 1, j <= Length[L1],
If[L2[[i + j - 1]] != L1[[j]], Break;];
j++;
];
If[j == Length[L1] + 1,
Return[ True];];
i++; ]; Return [False]; ]