MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to navigate the documentation?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110227] Re: How to navigate the documentation?
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Wed, 9 Jun 2010 07:20:45 -0400 (EDT)
  • References: <huaq0g$747$1@smc.vnet.net>

> On 6/3/2010 5:39 AM, kj wrote:
>> This question is about the Mathematica documentation, but it would
>> more helpful to pose it in terms of an example question:
>>
>> "I have a file containing newline-separated records.  The fields
>> in each record are separated by tabs.  The number of fields varies
>> from one record to the next, but it always has the form 2*(n+1),
>> where n>= 3.  The first two fields are always alphabetic strings;
>> the remaining 2*n fields are real numbers (expressed using the "E"
>> notation: e.g. 1.23E-4 == 0.000123), and they represent n points
>> in R^2.  In summary records have the following form:
>>
>> <string>   <TAB>   <string>   <TAB>   <real>   <TAB>   ...<TAB>   <real>   <NL>
>>
>> I want to read this file into a Mathematica structure having the form
>>
>> {String, String, {{Real, Real}, {Real, Real}, {Real, Real}, ...}}
>> "
>>
>>
>> OK, now: The *challenge* is to find the answer to the question
>> above in the Mathematica documentation.
>>
>>
>> I'm sorry to say that, after *hours* of effort, I failed completely.
>>
>>
>> OK, here's a much simpler question:
>>
>> "In Mathematica, how do I convert the string "1.23E-4" the real
>> number 0.000123?"
>>
>> The *challenge* now is like before: find the answer to this (much
>> simpler) question in the Mathematica documentation.
>>
>> Again, after much effort, I was not able to answer even this simple
>> question using the Mathematica documentation.  Can it be done at
>> all???
>>
>>
>> Someone please show me how to navigate the Mathematica documentation
>> to answer basic questions like these.
>>
>> TIA!
>>
>> ~K
>>
>

I'd just like to add this to Murray's comments. You need to realise that 
the problems you have posed are 2 of hundreds or thousands of similar 
possible problems - you really can't expect the answers to all of them 
to be there on a plate!

Assuming you are new to Mathematica, it is better to work up to problems 
like this by exploring some of the examples in the documentation - say 
relating to input/output, strings vs expressions, etc. Starting with the 
(moderately tricky) problems that you need to solve immediately, may not 
be the best approach. You should be encouraged that there usually is a 
way of doing what you want - for example, some packages would not have 
enough flexibility to let you input information in an arbitrary format.

As regards you other challenge, here is some code to kick you off. It 
will read your file as a list of lists of strings.

ReadList["~/hope.dat", Word, WordSeparators -> {"\t", " "}]

{ {"alpha", "beta", "1.6"}, etc.

You will still need to separate out the genuine strings and the strings 
that represent real numbers!

David Bailey

www.dbaileyconsultancy.co.uk





  • Prev by Date: Re: SendMail under Mac OS X
  • Next by Date: Re: Lists: Row Vectors vs. Column Vectors. (feels like such a silly
  • Previous by thread: Re: How to navigate the documentation?
  • Next by thread: Re: difficulty in calculating first two terms of an