# Unexpected output from oddSublists [duplicate]

I have just bought Mathematica and I'm in the process of plowing through Shifrin's great book. On page 74 the function oddSublists doesn't give me the expected output.

Since I'm a true beginner, I of course suspect mistakes on my behalf. I get: {{}, {, 2}, {, 2, 3, 4, 5}, {, 2, 3, 4, 5, 6}}

However the function oddSublistsNew gives me the expected output.{{1}, {1, 2}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}

And here is the code I forgot to include:

Clear[oddSublists];
oddSublists[x_List] :=
Part[x, Union[
Flatten[Cases[
Map[First,
Split[Position[x, _?OddQ], First[#1] == First[#2] &], {2}],
y_List /; OddQ[Length[y]]]]]]

• Welcome to Mathematica.Stackexchange. We prefer self-contained questions, so it would be better if you could post the code for oddSublists and ask why it doesn't work. – C. E. Mar 8 '14 at 21:47
• I suspect a transcription error, so as @Pickett notes please post the code you are actually using. – Mr.Wizard Mar 8 '14 at 21:48
• With complextestlist1 = Range /@ Range[6] the code you posted gives me the expected output. – C. E. Mar 8 '14 at 22:11
• @Pickett: That's odd. I run the complextestlist1 = Range /@ Range[6]on the line before oddSublists[] and that output looks correct: {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}but the function returns the before mentioned output. – MathLind Mar 8 '14 at 22:14
• @MathLind Try restarting your kernel and run the code again. Can't see why it would help in this particular scenario, but it's a thing to try. – C. E. Mar 8 '14 at 22:53

It seems that I have found the cause of my problem. Since I do not use an English keyboard, I often need to press Alt and Shift keys to obtain a } or ]. Sometimes I accidentally press ctrl or other key combinations. This seems to create three problems: 1. The notebook alerts with an orange color despite no visible errors. 2. The notebook alerts with a brown color and backspacing seems to be hampered. 3. The code does not work, in spite of no visible problems.