I have now seen different elegant ways to layout code on this forum.
As a beginner, I would like to have your advises on the best way to layout code like the one below.
It is ugly,not optimal, probably even stupid, but may the expert programmers pardon me, I use it as a “worst case scenario”.
The purpose for the novice I am is clarity.
rejection[disp_, fixationNOtoConsiderForDuration_, durationLimit_,
minDistance_] :=
With[{fakedata = consider[t4dataLAEH10, 9, disp, {17, 18, 11}]},
With[{num =
Flatten[Position[
Take[fakedata[[All, 3]], fixationNOtoConsiderForDuration],
x_ /; (x > durationLimit)]]},
If[num =!= {},
With[{fakedata1 = Drop[fakedata[[All, {1, 2}]], Last@num]},
With[{num1 =
Flatten[Position[
Table[
Sqrt[((fakedata1[[fixation1, 1]] -
centerX)^2 + (fakedata1[[fixation1, 2]] -
centerY)^2)],
{fixation1, 1, Length@fakedata1}],
x_ /; (x < minDistance)]]},
If[num1 =!= {},
Delete[fakedata1[[All, {1, 2}]], List /@ num1],
fakedata[[All, {1, 2}]]]]],
With[{fakedata2 = fakedata[[All, {1, 2}]]},
With[{num2 =
Flatten[Position[
Table[
Sqrt[((fakedata2[[fixation2, 1]] -
centerX)^2 + (fakedata2[[fixation2, 2]] -
centerY)^2)],
{fixation2, 1, Length@fakedata2}],
x_ /; (x < minDistance)]]},
If[num2 =!= {},
Delete[fakedata2[[All, {1, 2}]], List /@ num2],
fakedata[[All, {1, 2}]]]]]]]]

I chose to do a full rewrite because the original is simply too far from my own style for me to format it as I would my own code.
I did not attempt to test this, so it is entirely possible something is broken, but I believe that most of it is correct.
I use Text Cells to describe the syntax of my functions. I typically embed
(* comments *)to explain the code, but if the explanations become very long, I move them to Text Cells as well.I included a comment explaining
func1. It is not a very helpful comment, but it serves as an example.Here is an image of my notebook at 75% magnification:
Cell expression for copy&paste: