Post Reply 
newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
08-17-2017, 06:40 PM (This post was last modified: 08-17-2017 06:44 PM by Claudio L..)
Post: #18
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-08-11]
(08-17-2017 02:46 PM)The Shadow Wrote:  After some extensive playing around with numbers, I've realized that there is a much-needed command.

Call it SNFMT, which strips formatting from a number or algebraic, basically turning it into "#.A#".

Alternatively, a command ->NFMT. It takes a number or algebraic and a format string, and forces it into that format without changing the global setting. While more flexible than the previous, I think SNFMT covers by far the most common use case without the need for an additional input.

Another possibility I just thought of - instead of a command, a global flag that eliminates display formatting, much like STRIPCOMMENTS.

The issue is that a format convenient for human reading is not at all convenient for programmatic reading when turned into a string.

While there are workarounds for this issue, they're rather clunky, especially when you consider the variations that the LOCALE can introduce as well.

I thought about it, but I was thinking more on the lines of ->STR. Something like ->FMTSTR which does ->STR with a temporary format override. The argument would be just as flexible as SETNFMT is now (for those unaware, you can read about it on the newRPL wiki), and it could decompile any object, not just a number.
I still need to think about a temporary LOCALE override but keeping the arguments simple. Perhaps I'll add Locale support to the format string somehow.

As it is now, it's quite easy to write a wrapper to achieve this:

  GETLOCALE 'tmplocale' LSTO GETNFMT 'tmpfmt' LSTO { #2Eh #2009h
  #2009h #2Ch } →UTF8 SETLOCALE { "#.A#." 0.000000000001 "#.A#.E*"
  1000000000000 "#.A#.E*" } SETNFMT 0 'err' LSTO IFERR →STR
    1 'err' STO 
  tmplocale SETLOCALE tmpfmt SETNFMT IF err THEN

PS: The code above was written on the simulator, tested then copy/paste straight into this post. It's my favorite new feature of the newRPL simulator...
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-08-11] - Claudio L. - 08-17-2017 06:40 PM

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