Post Reply 
Calculators that allow direct operations on data stored on persistent storage?
03-01-2018, 06:15 PM
Post: #12
RE: Calculators that allow direct operations on data stored on persistent storage?
Here's an example of some helper routines that would translate some of your data back and forth between a list format and storage format. The ListExt library is required for several of the commands. I realize that your actual data doesn't match the format I'm using here, but I wanted to show several different examples in these two routines to illustrate how the conversions could be done.

In the above example, a vector was shown that appeared to have the data for a given day. I've converted it to a list for this example:
Code:
{ 20.062017 5. 4. 0. 2. 4. 3. 3. 4. 2. 3. 0. 4. 4. 3. 4. 2. 0. 0. 360. }

Using that same data as the starting point, the following code will convert the list to a string representation:
Code:
\<<
  @ convert date to padded offset
  LPOP 1.012017 SWAP DDAYS 1E5 + LPUSH

  @ pad final number
  LPOPR 1E3 + +

  @ convert list to integer
  NL\->I

  @ convert integer to string of "safe" ascii chars
  92 I\->BL NL\->S 35 CHR+
\>>

The padding is required to make sure that the first and last entries always use a consistent number of digits.

The result of the above routine with the specified data becomes "@[PXTS*M'H4iT7". That's not very useful in terms of readability, but for storage it's only 19 bytes compared to the 71 bytes used by the list. You could easily save even more by stringing together multiple day's worth of entries.

The following is the reciprocal to the above:
Code:
\<<
  @ expand alpha string to integer string
  -35 CHR+ S\->NL 92 BL\->I \->STR

  \-> str
  \<<
    @ convert date part
    1.012017 str 2 6 SUB STR\-> DATE+

    @ convert single digit entries
    str 7 24 SUB -48 CHR+ S\->NL +

    @ convert final entry
    str 26 28 SUB STR\-> +
  \>>
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Calculators that allow direct operations on data stored on persistent storage? - DavidM - 03-01-2018 06:15 PM



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