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


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

Re: Transforming/expanding a list

Started byDana DeLouis <dana01@me.com>
First post2012-09-09 09:12 +0000
Last post2012-09-09 09:12 +0000
Articles 1 — 1 participant

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


Contents

  Re: Transforming/expanding a list Dana DeLouis <dana01@me.com> - 2012-09-09 09:12 +0000

#11680 — Re: Transforming/expanding a list

FromDana DeLouis <dana01@me.com>
Date2012-09-09 09:12 +0000
SubjectRe: Transforming/expanding a list
Message-ID<k2hmh8$pto$1@smc.vnet.net>
> real numbers, separating some number of Strings

Hi.  If it's really just any String, perhaps another idea:

v={1,2,"Null", 3,"Null2", "Null3",4,5,"Null4",6};

FoldList[If[StringQ[#2],#1,#2]&, First[v], Rest[v]]

{1,2,2,3,3,3,4,5,5,6}

= = = = = = = = = =
HTH  :>)
Dana DeLouis
Mac & Mathematica 8
= = = = = = = = = =



On Thursday, September 6, 2012 4:15:28 AM UTC-4, Mark Coleman wrote:
> I'm working on some Mathematica code that will help transform a large set of lists drawn from my company's legacy database systems. A typical row of the raw data looks like
> 
> {x1,NULL,NULL,x2,NULL,NULL,NULL,NULL,x3,NULL,NULL,x4,x5,NULL} ...
> 
> The lists are sequences of real numbers, separating some some number of Strings which for convenicence sake we call "NULL" (as opposed to a proper Mathematica Null). The goal is to create a new list where each NULL is replaced by the real number that most recently proceeds it (note that any number of NULLs may occur before or after any real values). I would like the code to return
> 
> {x1,x1,x1,x2,x2,x2,x2,x2,x3,x3,x3,x4,x5,x5}
> 
> 
> Thanks
> Mark

[toc] | [standalone]


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


csiph-web