Draft
Conversation
`strlen_(STRING)' gives the number of characters in STRING.
`substr_(STRING,POS,LEN)' gives the substring of STRING starting from POS and with the length of LEN.
Collaborator
Author
|
FYI: if your pull request is still incomplete and needs more work, then there is the "Draft" feature for pull requests in GitHub. Even if your work is in progress, creating a draft pull request to get others' feedback sometimes be beneficial (I have changed the status of this pull request to "Draft"). |
Collaborator
Author
|
Note: I found 1d4b775 added Example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Although this may be a "feature creep" and I'm not sure whether many people find it useful or not, I would like to make a "Work in Progress" pull request, hoping this may stimulate other discussions.
As far as I know, there is no way/trick to extract a part of a string in FORM. So I experimentally implemented
substr_(STRING,POS,LEN)macro, which is more or lesssubstrof Perl and PHP but the first character is at POS=1. (Note that it is notsubstring_(STRING,FROM,TO)).POSandLENare somewhat extended to non-positive and negative integers, respectively. Especially,LEN=-1means the actual length ofSTRING.An application is defining a procedure with optional parameters:
which accepts
#call Proc1(x,expand=2)as well as#call Proc1(x),#call Proc1(x,expand)or#call Proc1(x,noexpand).This branch also contains an implementation of
strlen_(STRING), but it is not primitive in the sense that it can be implemented based onsubstr_:Other string operations like
strreplace_(STRING,OLD,NEW)can also be implemented based onsubstr_.