I've recently started a course in which I am learning how to solve different problems using Mathematica. A large part of the course covers creating your own functions. The thing is I don't like how my code looks.
Take for example the following:
CreateTuples[list_, size_] :=
If[list != {},
Prepend[
CreateTuples[Take[list, size-Length[list]], size],
Take[list, size]
], (* Prepend *)
{}
] (* If *)
This example is still small and simple, but already has some weird constructions like the {} in the If.
Are there any general tips or documents that describe some good styling rules for notebook files?
Also, while my example uses a function, my remarks also go for large expressions of other kinds. I just want to keep everything readable for myself and others.
But it might just be the software developer in me that is not used to bracketing like this.
Length@lst!=0and usingCreateTuples[list_List,size_]. But is this what the problem is? – acl Dec 4 '12 at 19:01createTuples. Global symbols starting with uppercase characters should be reserved to the Mathematica developers. – m_goldberg Dec 5 '12 at 0:52Ifstatement completely and terminate the recursion by defining a special caseCreateTuples[{},_]:={}– Simon Woods Dec 5 '12 at 10:44