Created
July 11, 2018 23:20
-
-
Save nedzadarek/affbef08e88596839345e13269f32d06 to your computer and use it in GitHub Desktop.
This file contains 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
Red[ | |
author: "Nędza Darek" | |
] | |
str: "a1bcvcvba2mcbncva3z" | |
find str "a" | |
iterator: copy #() | |
find-next: func [ | |
str candidate | |
/local | |
][ | |
iterator/candidate: candidate | |
iterator/__series: str | |
iterator/value: find iterator/__series iterator/candidate | |
iterator/next: func [][ | |
iterator/__series: next iterator/value | |
iterator/value: find iterator/__series iterator/candidate | |
iterator | |
] | |
iterator | |
] | |
probe it: find-next str "a" | |
comment { | |
#( | |
candidate: "a" | |
__series: "a1bcvcvba2mcbncva3z" | |
value: "a1bcvcvba2mcbncva3z" | |
next: func [][ | |
iterator/__series: next iterator/value | |
iterator/value: find iterator/__series iterator/candidate | |
iterator | |
] | |
) | |
} | |
; comment section has only changing part of the map | |
probe it/next | |
comment { | |
__series: "1bcvcvba2mcbncva3z" | |
value: "a2mcbncva3z" | |
} | |
probe it/next | |
comment { | |
__series: "2mcbncva3z" | |
value: "a3z" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No error checking & using global word.