 
 
 
 
 
 
Re: Using Map or Thread over selected parts of nested lists
- To: mathgroup at smc.vnet.net
- Subject: [mg95914] Re: Using Map or Thread over selected parts of nested lists
- From: dh <dh at metrohm.com>
- Date: Thu, 29 Jan 2009 05:59:50 -0500 (EST)
- References: <glpfhn$knq$1@smc.vnet.net>
Hi Paul,
use the following statement after setting "source":
source=Switch[source,
{_ ..},source,
$Canceled,{},
_,{source}
]
this will give a list, empty if Canceled is chosen.
hope this helps, Daniel
Paul Ellsmore wrote:
> Hi,
> 
>  
> 
> 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:
> 
>  
> 
> List1={{header,header},{header,header},{header,header},{frequency1,
> complexnumber1},{frequency2, complexnumber2},{frequency3, complexnumber4}.}
> 
>  
> 
> On very many occasions I want to deal with :
> 
>  
> 
> List2={{frequency1, realpart1},{frequency2, realpart2},{frequency3,
> realpart4}.}
> 
>  
> 
> 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
> grateful.
> 
>  
> 
> 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,
> 
>  
> 
> Paul.
> 
>  
> 
>  
> 
>  
> 
> Dr. Paul A. Ellsmore
> 
>  
> 
> Nanion Limited
> 
> Oxford Centre for Innovation
> 
> Mill Street
> 
> Oxford
> 
> United Kingdom
> 
> OX2 0JX
> 
>  
> 
> Tel: +44 (0) 1865 811175
> 
> Fax: +44 (0) 1865 248594

