Re: a beginner's question
- To: mathgroup at smc.vnet.net
- Subject: [mg77840] Re: a beginner's question
- From: Szabolcs <szhorvat at gmail.com>
- Date: Mon, 18 Jun 2007 06:54:48 -0400 (EDT)
- Organization: University of Bergen
- References: <f5048j$pup$1@smc.vnet.net>
tung tran wrote:
> I am a beginner in Mathematica and in programming. I read the book "An Introduction to Programming with Mathematica".
> Page 155:
>
> FindSubsequence[lis_List, subseq_List] := Module[{p}, p = Partition[lis, Length[subseq], 1]; Position[p, Flatten[{___, subseq, ___}]]]
>
> I want to know more about the role of Module function and " ; " in these lines. I have read documentation about Module function but it doesn't help me much in understanding this line of code. Thanks for helping me !
>
> Regards,
> Tung Anh
Now I cannot give you a better explanation of Module[] than the official
documentation.
http://reference.wolfram.com/mathematica/ref/Module.html
http://reference.wolfram.com/mathematica/tutorial/ModulesAndLocalVariables.html
But I would like to draw your attention to the following:
Your question is not very clear. You are simply stating that you don't
understand the role of Module in a particular line of code, but I
honestly don't see how this particular use of Module[] is different from
any other use. You should try to tell us what is exactly that you did
not understand in the documentation. Are the examples given there
clear? How are they different from this particular example that you
posted? Have you tried experimenting with Module[] a little bit? If
yes, what were the results? Were they different from what you expected?
If you don't understand what Module[] is good for in this example,
have you tried removing it? Have you looked up ";" as well?
If the Help Browser was not helpful, then the posts restating what is
already written in the documentation will not be any better.
My point is that if you formulate the question more clearly, often you
will find that you don't even need to ask it because you already have
the answer! But even if you *do* need to ask it, the replies you'll get
will be much more useful.
There is an anectode about Paul Dirac, that during the question session
after one of his lectures, a student said: "Professor, I don't
understand that formula at the right side of the blackboard."
"That is not a question", Dirac replied, "it is a statement. Next
question, please."
Szabolcs