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


Groups > comp.soft-sys.math.mathematica > #11653

Re: Transforming/expanding a list

From Adriano Pascoletti <adriano.pascoletti@uniud.it>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Transforming/expanding a list
Date 2012-09-07 09:01 +0000
Message-ID <k2cd54$f5j$1@smc.vnet.net> (permalink)
References <20120906081415.0241D684C@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


In[1]:= (If[#1 =!= NULL, save = #1, save] & ) /@ {x1, NULL, NULL, x2, NULL,
NULL,  NULL, NULL,  x3, NULL, NULL, x4, x5, NULL}
Out[1]= {x1, x1, x1, x2, x2, x2, x2, x2, x3, x3, x3, x4, x5, x5}


Adriano Pascoletti

2012/9/6 Mark Coleman <markspcoleman@gmail.com>

> 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
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Transforming/expanding a list Adriano Pascoletti <adriano.pascoletti@uniud.it> - 2012-09-07 09:01 +0000

csiph-web