MathGroup Archive 2009

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

Search the Archive

Using Map or Thread over selected parts of nested lists

  • To: mathgroup at
  • Subject: [mg95819] Using Map or Thread over selected parts of nested lists
  • From: "Paul Ellsmore" <paul.ellsmore at>
  • Date: Wed, 28 Jan 2009 06:29:14 -0500 (EST)



I am currently working with a trial version of Mathematica 7, particularly
with an interest in building a graphical user interface. I don't have a
great familiarity with Mathematica, but I am trying hard to get to grips
with a Mathenatica-style of thinking, and the way lists can be manipulated
in particular. I have two questions, answers to which would help me a lot:


1)      My GUI allows the user to select some data files to work with. I use
the code:


source = SystemDialogInput[FileOpen]


This returns the full path for each file selected by the user - very
convenient and user-friendly. My problem is that "source" is returned as a
string (ie an atom) if one file is selected, but a nested list if multiple
files are selected. I have similar instances in many parts of my program
where the user might be working with one list of data or multiple lists, and
I think the same issue will arise. So I would like to know if there is a way
of forcing (in this case) "source" to be returned as a nestedlist type, even
if the length of that list is one?


2)      I have data in the format:


complexnumber1},{frequency2, complexnumber2},{frequency3, complexnumber4}.}


On very many occasions I want to deal with :


List2={{frequency1, realpart1},{frequency2, realpart2},{frequency3,


Or some other trivial transform of complexnumbern. I have been through the
VirtualBook, and Documentation centre, and tried various forms of Map and
Thread, but I cannot find a way of "mapping" or "threading" a function like
Re[expr] over one element of part of a list, as in:


List2={{frequency1, Re[complexnumber1]},{frequency2,
Re[complexnumber2]},{frequency3, Re[complexnumber4]}.}


If someone could give me a pointer to the correct syntax, I would be very


At present, I am getting the results I want by using Ifs and Do loops, to
deconstruct and reconstruct my lists, but I feel that is the wrong way to
approach things - I want to use Mathematica's strengths, not force it to use
a C type approach, just because that's what I am comfortable with.


Any suggestions gratefully received,



Cheers in advance,






Dr. Paul A. Ellsmore


Nanion Limited

Oxford Centre for Innovation

Mill Street


United Kingdom



Tel: +44 (0) 1865 811175

Fax: +44 (0) 1865 248594

  • Prev by Date: BarChart[] axis label bug in v7 Linux (Windows, OSX?)
  • Next by Date: Significant slow-down with Mathematica 7 (vs 6).
  • Previous by thread: Re: BarChart[] axis label bug in v7 Linux (Windows, OSX?)
  • Next by thread: Re: Using Map or Thread over selected parts of nested lists