Menu

#53 Add a way to get the stack length

0.6.4
open
aditsu
None
2015-04-27
2015-04-27
Optimizer
No

Currently, the shortest way to get the length of stack on the stack itself is:

]:B~B,

which is 6 bytes. It would be nice to have a way to put the length of stack on the stack in 2 bytes using some e? command

Discussion

  • Optimizer

    Optimizer - 2015-04-27

    Not to mention that the above 6 byte code does not work if the stack contains just characters

    For example,

    ': '. '- ]:B~B,
    

    will try to evaluate the string ":.-" and fail.

     
  • user23013

    user23013 - 2015-04-27

    5 bytes:

    ]_,+~
    

    Works even if there are only characters.

     
    • Optimizer

      Optimizer - 2015-04-27

      Cool. Used this in my answer to save 1 byte! But it would still be nice to get a 2 byte operator for it :)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.