I've updated my GitHub to the following, which adopts Brian's "starts with"
(I can't count how many times I've had to re-remember that "starts with" is
faster than comparing to char 1 through ) and added minor
optimizations to the wrapping-up code.
gc
function allOffsets D,S,pCase,pNoOverlaps
On Sun, Nov 4, 2018 at 7:11 PM Mark Wieder via use-livecode <
use-livecode@lists.runrev.com> wrote:
>
> If you're looking for 'romeo' in pText, would you set pOverlaps to true
> or to false?
I'd set it to false, there's no way for "romeo" to overlap. But even if I
were looking for "radar", which
On Sun, Nov 4, 2018 at 7:42 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:
> Simply add 1 to the last offset pointer. If after the first iteration you
> return 1, then set the charsToSkip to 2 instead of offset +
> len(searchString) if you take my meaning.
>
> Bob S
>
The
Here's an image of the stack in my fork of the repo:
https://github.com/bwmilby/alloffsets/blob/bwm/bwm/stack_allOffsets_card_id_1018.png
On Sun, Nov 4, 2018 at 10:07 PM Brian Milby wrote:
> I’m working on an update to the stack now. Moving buttons to the left side
> to make it easier to add mo
I’m working on an update to the stack now. Moving buttons to the left side to
make it easier to add more.
Thanks,
Brian
On Nov 4, 2018, 10:02 PM -0600, Mark Wieder via use-livecode
, wrote:
> On 11/4/18 4:45 PM, Brian Milby via use-livecode wrote:
> > My updated solution always looks for overlap
On 11/4/18 4:45 PM, Brian Milby via use-livecode wrote:
My updated solution always looks for overlap but if none are found it uses
optimized versions of the search (private functions instead of inside the main
function). I special case for no overlap and a single overlap in the delimiter.
It i
Simply add 1 to the last offset pointer. If after the first iteration you
return 1, then set the charsToSkip to 2 instead of offset + len(searchString)
if you take my meaning.
Bob S
> On Nov 2, 2018, at 17:43 , Geoff Canyon via use-livecode
> wrote:
>
> I like that, changing it. Now availa
On 11/4/18 6:49 PM, Geoff Canyon via use-livecode wrote:
I'm not sure I agree that it would be so unlikely to know that overlaps
won't occur (or that it's unreasonable to not want them). If I'm looking
for every instance of "romeo" in romeo and juliet, then obviously I'm not
expecting, nor do I
On Sun, Nov 4, 2018 at 4:34 PM Mark Wieder via use-livecode <
use-livecode@lists.runrev.com> wrote:
> On 11/4/18 10:40 AM, Geoff Canyon via use-livecode wrote:
> > I also added a "with overlaps" option.
>
> My problem with the pWithOverlaps parameter is that is requires a priori
> knowledge of the
My updated solution always looks for overlap but if none are found it uses
optimized versions of the search (private functions instead of inside the main
function). I special case for no overlap and a single overlap in the delimiter.
It is about the same speed as Geoff’s.
Thanks,
Brian
On Nov 4
On 11/4/18 10:40 AM, Geoff Canyon via use-livecode wrote:
I also added a "with overlaps" option.
My problem with the pWithOverlaps parameter is that is requires a priori
knowledge of the data being consumed. If you already know there are
overlaps then you'd set the parameter to true. If you d
Logic matches my solution. I also validated my solution using just the
offset function. Speed hit for with overlap is similar. One possible
optimization:
put kList is not empty into pWithOverlaps
If with overlaps was requested but the source delimiter did not contain any
overlaps, then the ext
Alex, good catch! The code below and at
https://github.com/gcanyon/alloffsets now puts a stop character after the
string to prevent the error you found. I also added a "with overlaps"
option. I think this is correct, and about as efficient as possible, but
thanks to anyone who finds a bug or a fast
I've posted a binary stack version that includes my version. I cloned and
made a "bwm" branch in my clone. Here's the direct link to the script with
the posted code (updated to use private functions):
https://github.com/bwmilby/alloffsets/blob/bwm/bwm/allOffsets_Scripts/stack_allOffsets_button_i
Good catch Alex. My code was closer, but didn't handle repeating
characters correctly. Here is an updated version.
function allOffsets2 D,S,pCase
local dLength, C, R
-- returns a comma-delimited list of the offsets of D in S
set the caseSensitive to pCase is true
set the itemDel to D
Hi Geoff,
unfortunately the impact of overlapping delimiter strings is more severe
than simply not finding them. The code on github gets the wrong answer
if there is an overlapping string at the very end of the search string, e.g.
alloffsets("", "a") wrongly gives 1,5,10
I su
Here is something... probably needs some optimization
function allOffsets2 D,S,pCase
local dLength, C, R
-- returns a comma-delimited list of the offsets of D in S
set the caseSensitive to pCase is true
set the itemDel to D
put length(D) into dLength
put 1 - dLength into C
if
Oh dear - answering my own posts rarely a good sign :-)
On 03/11/2018 02:10, Alex Tweedly via use-livecode wrote:
On 03/11/2018 00:43, Geoff Canyon via use-livecode wrote:
One thing I don't see how to do without significantly impacting
performance
is to return all offsets if there are o
On 03/11/2018 00:43, Geoff Canyon via use-livecode wrote:
I like that, changing it. Now available at
https://github.com/gcanyon/alloffsets
One thing I don't see how to do without significantly impacting performance
is to return all offsets if there are overlapping strings. For example:
allOffs
I like that, changing it. Now available at
https://github.com/gcanyon/alloffsets
One thing I don't see how to do without significantly impacting performance
is to return all offsets if there are overlapping strings. For example:
allOffsets("aba","abababa")
would return 1,5, when it might be reas
how about allOffsets?
Bob S
> On Nov 2, 2018, at 09:16 , Geoff Canyon via use-livecode
> wrote:
>
> All of those return a single value; I wanted to convey the concept of
> returning multiple values. To me listOffset implies it does the same thing
> as itemOffset, since items come in a list. H
All of those return a single value; I wanted to convey the concept of
returning multiple values. To me listOffset implies it does the same thing
as itemOffset, since items come in a list. How about:
offsets -- not my favorite because it's almost indistinguishable from offset
offsetsOf -- seems a t
It probably should be named listOffset, like itemOffset or lineOffset.
Bob S
> On Nov 1, 2018, at 17:04 , Geoff Canyon via use-livecode
> wrote:
>
> Nice! I *just* finished creating a github repository for it, and adding
> support for multi-char search strings, much as you did. I was coming
Nice! I *just* finished creating a github repository for it, and adding
support for multi-char search strings, much as you did. I was coming to the
list to post the update when I saw your post.
Here's the GitHub link: https://github.com/gcanyon/offsetlist
Here's my updated version:
function offs
Hi Geoff,
thank you for this beautiful script.
I modified it a bit to accept multi-character search string and also for case
sensitivity.
It definitely is a lot faster for unicode text than anything I have seen.
-
function offsetList D,S, pCase
-- returns a comma
25 matches
Mail list logo