MathGroup Archive 2006

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

Search the Archive

Re: Inserting Blank Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68288] Re: [mg68231] Inserting Blank Lists
  • From: Adriano Pascoletti <pascolet at dimi.uniud.it>
  • Date: Mon, 31 Jul 2006 03:45:58 -0400 (EDT)
  • References: <200607300847.EAA25113@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bruce,
three possible alternatives to your solution:

L={{"a","b"},{"c","d"},{"e","f"}};
Map[Sequence@@{#,{}}&,L]

{{a,b},{},{c,d},{},{e,f},{}}



Replace[L,{x_ -> Sequence[x,{}]}, {1}]

{{a,b},{},{c,d},{},{e,f},{}}


Join@@Transpose[{#,Table[{},{Length@#}]}]&@L

{{a,b},{},{c,d},{},{e,f},{}}


Adriano Pascoletti

On 30 lug 2006, at 10:47, Bruce Colletti wrote:

> Re Mathematica 5.2.
>
> The code below inserts a null list between L-elements:
>
> L={{"a","b"},{"c","d"},{"e","f"}};
> Most@Flatten[Map[{#,{}}&,L],1]
>
> Out[9]=
> {{a,b},{},{c,d},{},{e,f}}
>
> What is a shorter way to do this?  Thankx.
>
> Bruce
>


  • Prev by Date: Re: {x},{y} -> {x,y} ?
  • Next by Date: Re: Replacing Numbers in a List
  • Previous by thread: Inserting Blank Lists
  • Next by thread: Re: Inserting Blank Lists