HP 48GX - Store Coordinates in a List
03-28-2021, 09:08 PM (This post was last modified: 03-28-2021 09:08 PM by Han.)
Post: #3
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: HP 48GX - Store Coordinates in a List
Leave your data list as-is. Instead, create a new object (string?) whose characters represent the point-number within the list. Let's say we use a 2-character string of indices (there are 256 characters, so that gives us a space of $$256^2 = 65536$$ points. The "first" point is point 100, which in base 256 is simply the 100th character. So that would be a character 0 followed by character 100 (or the letter "d"). Then the next two characters would be character 1 followed by character 244 since $$500 = 1\cdot 256^1 + 244 \cdot 256^0$$.

Thus when you want to know which point the $$n$$-th element in your data list is, you simply get the $$2n$$-th and $$(2n+1)$$-th characters and convert from base 256 back to base 10. Moreover, if you want to search for the $$k$$-th point, you simply traverse your string two characters at a time and compute the decimal representation of those two characters and check to see if it matches the value $$k$$. This would be much faster because actual lists are composite objects. Thus, when "skipping" objects in side a list, the cost is very high (as opposed to simply traversing a string 2 characters at a time and doing a quick computation each time).

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

 Messages In This Thread HP 48GX - Store Coordinates in a List - MNH - 03-28-2021, 04:21 AM RE: HP 48GX - Store Coordinates in a List - Giuseppe Donnini - 03-28-2021, 12:25 PM RE: HP 48GX - Store Coordinates in a List - MNH - 04-01-2021, 09:00 PM RE: HP 48GX - Store Coordinates in a List - Joe Horn - 04-02-2021, 12:28 AM RE: HP 48GX - Store Coordinates in a List - Han - 03-28-2021 09:08 PM RE: HP 48GX - Store Coordinates in a List - MNH - 03-30-2021, 10:44 PM RE: HP 48GX - Store Coordinates in a List - MNH - 04-02-2021, 01:27 AM RE: HP 48GX - Store Coordinates in a List - BruceH - 03-31-2021, 09:27 PM RE: HP 48GX - Store Coordinates in a List - MNH - 04-01-2021, 09:21 PM RE: HP 48GX - Store Coordinates in a List - BruceH - 04-03-2021, 02:25 PM RE: HP 48GX - Store Coordinates in a List - Han - 04-13-2021, 07:44 AM RE: HP 48GX - Store Coordinates in a List - MNH - 04-13-2021, 11:00 PM RE: HP 48GX - Store Coordinates in a List - Han - 04-14-2021, 06:50 AM RE: HP 48GX - Store Coordinates in a List - MNH - 04-15-2021, 01:21 AM

User(s) browsing this thread: 1 Guest(s)