MathGroup Archive 2005

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

Search the Archive

Re: Tilting at Windmills?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62156] Re: Tilting at Windmills?
  • From: dana.onthebeach at comcast.net (Dana DeLouis ("dana.onthebeach at comcast.net"))
  • Date: Sun, 13 Nov 2005 02:08:36 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

HI.  Here's my attempt.


f[v_List]:=Module[{t},
 t=Flatten[Thread[{v,v,v,v}]];
 t=Take[t,{4,-4}];
 Partition[t,2,2]
]

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

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

HTH
Dana DeLouis


"Matt" <anonmous69 at netscape.net> wrote in message news:dl1jta$1m$1 at smc.vnet.net...
> Hello,
>  Where there's a chance of success, I tend to agonize over details of
> implementation.  Memory usage is one such area.  Here is a statement of
> a problem I was trying to solve in Mathematica:
> 
> Given a list of the following form:{x1,x2,x3,...,xn-1,xn} I want to
> develop an algorithm that will iterate over the input list to produce
> output of the following
> form:{x1,x2,x2,x2,x2,x3,x3,x3,x3,x4,x4,x4,x4,x5,...,xn-2,xn-1,xn-1,xn-1,xn-1,xn}
> which will then need to be partitioned to end up in the following form:
> {{x1,x2},{x2,x2},{x2,x3},{x3,x3},{x3,x4},{x4,x4},{x4,x5},...,{xn-2,xn-1},{xn-1,xn-1},{xn-1,xn}}
> which means that if I had a flattened list of length'n' as input, then
> the new flattened list would have a length of 4*(n-2)+2
> 
> Here is my first solution...

<snip>


  • Prev by Date: Re: Re: Re: Re: Mathematica 1
  • Next by Date: Re: extract from list and keep track
  • Previous by thread: Re: Tilting at Windmills?
  • Next by thread: Re: Tilting at Windmills?