help: divide a list into other two
|
05-19-2015, 09:23 PM
Post: #1
|
|||
|
|||
help: divide a list into other two
hi,
to calculate MIRR (modified IRR) I need to divide list L1 in this way: if L1(j) < 0 -> flneg(j), if L1(j) >=0 -> flpos(j) with Code:
in both lists there is 0 at the correspondent place in the other list (i.e. {-1, 2, 3, -4} -> {-1, 0, 0, -4} and {0, 2, 3, 0} I need {-1, -4} and {2, 3} please, help TIA! Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-19-2015, 10:01 PM
(This post was last modified: 05-19-2015 10:04 PM by Didier Lachieze.)
Post: #2
|
|||
|
|||
RE: help: divide a list into other two
This should work:
Code: flneg:=MIN(L1,0); flpos:=MAX(L1,0); You need to do it in two steps: flneg:=remove(0,MIN(L1,0)) doesn't work. |
|||
05-19-2015, 10:06 PM
Post: #3
|
|||
|
|||
RE: help: divide a list into other two
(05-19-2015 10:01 PM)Didier Lachieze Wrote: This should work: Thank you! quite ok, but there is a possibility that the original list has zeros among items (i.e {-100, 100, 100, 0, 0, 0, -50, -50, 100}) Any help for this? TIA salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-19-2015, 10:14 PM
Post: #4
|
|||
|
|||
RE: help: divide a list into other two
As in your program example you were testing L1(j)<0 and L1(j)>0 I assumed you wanted to discard the zeros.
So, where do you want the zeros to fall? In both lists? |
|||
05-19-2015, 10:18 PM
(This post was last modified: 05-19-2015 10:34 PM by salvomic.)
Post: #5
|
|||
|
|||
RE: help: divide a list into other two
(05-19-2015 10:14 PM)Didier Lachieze Wrote: As in your program example you were testing L1(j)<0 and L1(j)>0 I assumed you wanted to discard the zeros. I think only in flpos, positive... precisely, to calc MIRR I must have a list of positive values (and 0) and a list of negative, in the same order of original. Actually I've this list {-180000, 100000 (5 times), -100000 (5 times), 0 (9 times), 200000} that's {-180000, 100000, 100000, 100000, 100000, 100000, -100000, -100000, -100000, -100000, -100000, 0,0,0,0,0,0,0,0,0, 200000} The 9 zeros are period to discount... EDIT (see here page 193) positive list must also have a first element prepend, zero: {0, 100000, ..., 0, 0, ..., 200000} but this is another 0 (fix, I think) However, maybe the leading zeros are ok, I'm trying another way... ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-19-2015, 11:08 PM
Post: #6
|
|||
|
|||
RE: help: divide a list into other two
Try this:
Code: flneg:=remove("x->x>=0,L1"); |
|||
05-20-2015, 06:57 AM
Post: #7
|
|||
|
|||
RE: help: divide a list into other two
(05-19-2015 11:08 PM)Didier Lachieze Wrote: Try this: (05-19-2015 11:15 PM)DrD Wrote:(05-19-2015 10:01 PM)Didier Lachieze Wrote: This should work: thank you both! this tip is very interesting. ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)