[BASIC] List routine for eliminating values
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
- JoostinOnline
- Regular Member
- Posts: 133
- Joined: Wed 11 Jul, 2007 10:42 pm
- Location: Behind You
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
It works pretty good, the not-ing makes ever list value without a change from the last register as one - the boolean opposite of any change from value to value, meaning any list value that doesn't change from the last registers a change of zero, not(0)=1, everything else is not-ed to zero, so if organised in an ascending order, every list value without a change is stored as a one, which is sent to the end of the list. So once I change the dimension of the list, all those ones get cut off, and the corresponding values from list one get cut off too.King Harold wrote:doesn't the second sort have to be descending? (could be that I didn't understand it properly..)
augmenting a {0} to the list after not-ing it would help to make it a few microseconds faster I think
I'll try augmenting a zero after all that, thanks for the tip.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Well I don't get you, I thought your algorithm works like this:
Sort to place duplicate values next to each other
Make a delta-list (will have 0 at the index of any duplicate except the last one)
Not( the d-list..
append 0 to front to match size
use the list to key-sort the old list and chop the duplicates off
sort {2,3,1,2
dlist {1,2,2,3
not {1,0,1
augmnt0 {0,1,0
keysort {0,0,1,0
chop {1,2,3,2
{1,2,3
like so.
Sort to place duplicate values next to each other
Make a delta-list (will have 0 at the index of any duplicate except the last one)
Not( the d-list..
append 0 to front to match size
use the list to key-sort the old list and chop the duplicates off
sort {2,3,1,2
dlist {1,2,2,3
not {1,0,1
augmnt0 {0,1,0
keysort {0,0,1,0
chop {1,2,3,2
{1,2,3
like so.
Oh I see what you mean. I actually only stick that zero there since the p/q technique doesn't work for any roots that are 0 (y=x^2 would only yield a bunch of 1's in the possible root value list).
Other than that your exactly right.
I don't know why, but I don't need to line up the lists with an extra value in the delta list, maybe it's just a result of the strange ways I use basic.
Other than that your exactly right.
I don't know why, but I don't need to line up the lists with an extra value in the delta list, maybe it's just a result of the strange ways I use basic.