[Date Index]
[Thread Index]
[Author Index]
Re: Need a nice way to do this
*To*: mathgroup at smc.vnet.net
*Subject*: [mg40289] Re: [mg40279] Need a nice way to do this
*From*: "Mihajlo Vanevic" <mvane at eunet.yu>
*Date*: Sun, 30 Mar 2003 04:08:04 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
First rename a->1 b->2 (with s/.{a->1, b->2})
and try this (a 'more general version')
In[]:=
s = {1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 1};
In[]:=
t = Table[0, {Max[s]}];
sumt = 0;
g = (sumt++ - t[[#]]++) & /@ s
Regards,
Mihajlo Vanevic
mvane at EUnet.yu
2003-03-29
**************************************************************
* At 2003-03-29, 05:19:00
* Steve Gray, stevebg at adelphia.net wrote:
**************************************************************
> Given a list consisting of only two distinct values, such as
>s={a,b,b,a,a,a,b,a,b,a,a}, I want to derive a list of equal length
>g={0,1,1,2,2,2,4,3,5,4,4}. The rule is: for each position
>1<=p<=Length[s], look at list s and set g[[p]] to the number of
>elements in s to the left of p which are not equal to s[[p]].
> In a more general version, which I do not need now, s would
>not be restricted to only two distinct values.
>
> Thank you for any ideas, including other applications where
>this particular calculation is used. The current application is an
>unusual conjecture in geometry.
**************************************************************
Prev by Date:
**Re: Need a nice way to do this**
Next by Date:
**Re: Need a nice way to do this**
Previous by thread:
**Re: Need a nice way to do this**
Next by thread:
**Re: Need a nice way to do this**
| |