Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11369 > unrolled thread

Re: working with nested lists

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-08-16 05:57 +0000
Last post2012-08-16 05:57 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: working with nested lists Bob Hanlon <hanlonr357@gmail.com> - 2012-08-16 05:57 +0000

#11369 — Re: working with nested lists

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-08-16 05:57 +0000
SubjectRe: working with nested lists
Message-ID<k0i242$19o$1@smc.vnet.net>
"Unless an explicit Return is used, the value returned by Do is Null."

myList = {{{-33.355 Degree, 278.265}, {-33.486 Degree,
     155.871}, {-60.650 Degree, 27.534}}, {{-38.418 Degree,
     148.054}, {-165.173 Degree, 70.342}}};

m1 = Table[
   Table[{myList[[k, i, 1]],
     myList[[k, i, 2]] (-1)/Sin[myList[[k, i, 1]]]},
    {i, Length[myList[[k]]]}],
   {k, Length[myList]}];

m2 = ((# /. {a_, b_?NumericQ} -> {a, -b*Csc[a]}) & /@ myList);

m3 = Map[{#[[1]], -#[[2]]*Csc[#[[1]]]} &, myList, {2}];

m1 === m2 === m3

True


Bob Hanlon


On Wed, Aug 15, 2012 at 3:34 AM, Levente <lemonlev@mac.com> wrote:
> I'm trying to apply a transformation to a every element in a nested list. The issue is that each sub-list has a different length
>
> Example of the list:
> myList={{{-33.355 Degree, 278.265}, {-33.486 Degree,
>   155.871}, {-60.650 Degree, 27.534}},
> {{-38.418 Degree, 148.054}, {-165.173 Degree, 70.342}}};
>
> This is what I am trying and does not work:
> Do[
>  Table[{myList[[k, i, 1]], myList[k, i, 2]] (-1)/Sin[myList[[k, i, 1]]]}, {i,
>    Length[myList[[k]]]}], {k, Length[myList]}]
>
> Any tips?
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web