Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created July 11, 2018 23:20
Show Gist options
  • Save nedzadarek/affbef08e88596839345e13269f32d06 to your computer and use it in GitHub Desktop.
Save nedzadarek/affbef08e88596839345e13269f32d06 to your computer and use it in GitHub Desktop.
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"
}
@nedzadarek
Copy link
Author

No error checking & using global word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment