Re: ListManipulationQuestion
- To: mathgroup at smc.vnet.net
- Subject: [mg93176] Re: ListManipulationQuestion
- From: dh <dh at metrohm.ch>
- Date: Thu, 30 Oct 2008 02:01:18 -0500 (EST)
- References: <ge9f0p$95h$1@smc.vnet.net>
Hi Lynete,
something is fishy here. nextprice does not use successor? As written
nextprice[..] returns not 90.9091 but 100 delta_ld.
hope this helps, Daniel
lynette wrote:
> Hi:
> I try to encode a hash table in the name of list.
> successors[{s_Integer, {{nhu_Integer, nhd_Integer}, {nlu_Integer,
> nld_Integer}}}] := {
> {1, {{nhu + 1, nhd}, {nlu, nld}}},
> {1, {{nhu, nhd + 1}, {nlu, nld}}},
> {2, {{nhu, nhd}, {nlu + 1, nld}}},
> {2, {{nhu, nhd}, {nlu, nld + 1}}}
> }
>
> successors[{1, {{2, 3}, {0, 2}}}]
> {{1, {{3, 3}, {0, 2}}}, {1, {{2, 4}, {0, 2}}}, {2, {{2, 3}, {1, 2}}},
> {2, {{2, 3}, {0, 3}}}}
>
> I want to find the price of successor nodes given the price of current
> node
>
> nextprice[p_, n_] := price[p] Total[Flatten[(n[[2]] - p[[2]]) {{\
> [Delta]hu, \[Delta]hd}, {\[Delta]lu, \[Delta]ld}}]]
>
> It works for single node:
>
> price[{1, {{2, 3}, {0, 2}}}] = 100
>
> price[{2, {{2, 3}, {0, 3}}}] = nextprice[{1, {{2, 3}, {0, 2}}}, {2,
> {{2, 3}, {0, 3}}}]
> 90.9091
>
> However, it doesn't work when I tried to map it out:
>
> input: nextprice[{1, {{0, 0}, {0, 0}}}, #] & /@ successors[{1, {{0,
> 0}, {0, 0}}}]
> output: {120., 83.3333, 110., 90.9091}
>
> input: price[{1, {{1, 0}, {0, 0}}}]
> output: price[{1, {{1, 0}, {0, 0}}}]
>
> I cannot assign the price to each successor nodes. Does anybody know
> what is wrong with it? thanks alot.
>
--
Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>