I found a bug in my previous regexp-split implementation, and fixed now:
-code-
(define* (regexp-split regex str #:optional (flags 0))
(let ((ret (fold-matches
regex str (list '() 0 str)
(lambda (m p
On Fri 30 Dec 2011 16:12, Nala Ginrut writes:
> So the previous discussion didn't make this proc put into Guile?
> Now that so many people interested in this topic.
I think it would make a nice addition to (ice-9 regexp). I don't think
we need to capture the delimiters though; some other funct
Two hours ago, Daniel Hartwig wrote:
>
> I could not find any mention of this optional Emacs arg. you talk
> about; have a pointer for me?
It's the last optional argument of `split-string'. The last paragraph
in the documentation notes that when you call this function with just
a single argument
On 31 December 2011 11:21, Eli Barzilay wrote:
>> A good point. I'm interested to find out the reasoning behind
>> Perl's decision to drop empty strings.. Seems a strange thing to do
>> IMO.
>
> I think that there's a general tendency to make things "nice" and
> dropping these things for cases w
Just now, Daniel Hartwig wrote:
> On 31 December 2011 10:32, Eli Barzilay wrote:
> > 40 minutes ago, Daniel Hartwig wrote:
> >>
> >> I think Racket does the right thing by keeping *all* the empty
> >> strings in place.
> >
> > Well, I do think that Perl (as well as other libraries &
> > languages)
On 31 December 2011 10:32, Eli Barzilay wrote:
> 40 minutes ago, Daniel Hartwig wrote:
>> If two procedures are implemented they will be almost verbatim copies
>> of each other.
>
> Yeah, but that's not an argument in favor or against -- since you can
> switch between:
>
> (define (foo x [other-b
40 minutes ago, Daniel Hartwig wrote:
>
> How about having an optional argument to control the behaviour? The
> default could be to not include the groups, thus mimicking the
> output of Guile's `string-split' and `regexp-split' in other
> Schemes.
That can work, though I personally prefer a sep
Hello
On 31 December 2011 04:11, Eli Barzilay wrote:
> [I don't think that I'm subscribed to the Guile list, but feel free to
> forward it there.]
Copying back the list and Marijn.
> 5 hours ago, Marijn wrote:
>> On 30-12-11 12:52, Nala Ginrut wrote:
>> > I just expressed "I think group capturi
OK, I'll put this proc in my own lib since there's no regexp-lib but a
regexp-core in Guile. Anyway, it's almost completed now. One may copy the
final version if needed.
On Sat, Dec 31, 2011 at 12:26 AM, Neil Jerram wrote:
> Nala Ginrut writes:
>
> > Well, I see.
> > So the previous discussion d
Nala Ginrut writes:
> Well, I see.
> So the previous discussion didn't make this proc put into Guile?
> Now that so many people interested in this topic.
I'm afraid I can't recall what happened following that thread.
What feels important to me, though, is the elegance of the overall API.
There
Now that we have previous thread on this topic, I think it's no need to
format a patch.
Maybe this will solve the problem:
(define* (regexp-split regex str #:optional (flags 0))
(let ((ret (fold-matches
regex str (list '() 0 str)
(lambda (m prev)
(let* ((ll (car prev))
(start
On 30 December 2011 21:03, Neil Jerram wrote:
> Nala Ginrut writes:
>
>> hi guilers!
>> It seems like there's no "regexp-split" procedure in Guile.
>> What we have is "string-split" which accepted Char only.
>> So I wrote one for myself.
>
> We've had this topic before, and it only needs a search
On 30 December 2011 19:47, Nala Ginrut wrote:
> Forget to load (srfi-1 iota) ,again...
>
>
> On Fri, Dec 30, 2011 at 7:40 PM, Nala Ginrut wrote:
>>
>> Great! It's better now.
>> Here's the brand new patch~
I notice that this does not handle the case where there are no matches:
scheme@(guile-use
Well, I see.
So the previous discussion didn't make this proc put into Guile?
Now that so many people interested in this topic.
On Fri, Dec 30, 2011 at 9:03 PM, Neil Jerram wrote:
> Nala Ginrut writes:
>
> > hi guilers!
> > It seems like there's no "regexp-split" procedure in Guile.
> > What we
On 30 December 2011 21:23, Marijn wrote:
> Group capturing is useful, but the question is whether it is useful in
> the context of regexp-split. Maybe it is, maybe it isn't. Racket seems
> to be doing it differently than python, so I think that constitutes
> reason to look more closely. Certainly
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 30-12-11 12:52, Nala Ginrut wrote:
> I just expressed "I think group capturing is useful and someone
> didn't think that's true". If this is not what your last mail
> mean, I think it's better to ignore it.
Group capturing is useful, but the quest
Nala Ginrut writes:
> hi guilers!
> It seems like there's no "regexp-split" procedure in Guile.
> What we have is "string-split" which accepted Char only.
> So I wrote one for myself.
We've had this topic before, and it only needs a search for
"regex-split guile" to find it:
http://old.nabble.co
I just expressed "I think group capturing is useful and someone didn't
think that's true".
If this is not what your last mail mean, I think it's better to ignore it.
On Fri, Dec 30, 2011 at 7:48 PM, Marijn wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 30-12-11 11:56, Nala Ginru
27;Words', ', ', 'words', ', ', 'words', '.', '']
>> >>
>> >> >>> re.split('((,)?\W+?)', 'Words, words, words.')
>> >> ['Words', ', ', ',', 'wo
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 30-12-11 11:56, Nala Ginrut wrote:
> Hmm, interesting! I must confess I'm not familiar with Racket, but
> I think the aim of Guile contains practicality.
Not sure what you're trying to imply here or to which of my points
you're responding.
> So I
s, words, words.')
> >> ['Words', ', ', ',', 'words', ', ', ',', 'words', '.', None, '']
>
> FYI this can be achieved by changing the inner part to:
>
>(let* ...
> (s (substring string start end))
Hmm, interesting!
I must confess I'm not familiar with Racket, but I think the aim of Guile
contains practicality.
So I think regex-lib of Guile does this at least.
Anyway, I believe an implementation should do its best to provide any
useful mechanism for the user. Or it won't be popular anymore.
W
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 29-12-11 10:32, Nala Ginrut wrote:
> hi guilers! It seems like there's no "regexp-split" procedure in
> Guile. What we have is "string-split" which accepted Char only. So
> I wrote one for myself.
>
> --python code-
import re re.split(
On 30 December 2011 16:46, Nala Ginrut wrote:
> hi Daniel! Very glad to see your reply.
> 1. I also think the order: (regexp str) is strange. But it's according to
> python version.
> And I think the 'string-match' also put regexp before str. Anyway, that's an
> easy mend.
`regexp string' is also
Well, I realized it's a mistake. We can use fold-matches anyway.
On Fri, Dec 30, 2011 at 4:46 PM, Nala Ginrut wrote:
> hi Daniel! Very glad to see your reply.
> 1. I also think the order: (regexp str) is strange. But it's according to
> python version.
> And I think the 'string-match' also put r
hi Daniel! Very glad to see your reply.
1. I also think the order: (regexp str) is strange. But it's according to
python version.
And I think the 'string-match' also put regexp before str. Anyway, that's
an easy mend.
2. I think it's a little different to implement a flag as python version.
Since "
Hello
>>> On Thu, Dec 29, 2011 at 5:32 PM, Nala Ginrut
>>> wrote:
hi guilers!
It seems like there's no "regexp-split" procedure in Guile.
What we have is "string-split" which accepted Char only.
So I wrote one for myself.
--python code-
>>> import r
>>>
>>> --guile code---
>>> (regexp-split "([^0-9])" "123+456*/")
>>> ==>("123" "+" "456" "*" "" "/" "")
>>> --code end
>>>
ot;123+456*/")
>> [’123’, ’+’, ’456’, ’*’, ’’, ’/’, ’’]
>> code end---
>>
>> The Guile version:
>>
>> --guile code---
>> (regexp-split "([^0-9])" "123+456*/")
>> ==>("123" "+" "456" &quo
;([^0-9])" "123+456*/")
> ==>("123" "+" "456" "*" "" "/" "")
> ------code end
>
> Anyone interested in it?
>
>
From 7ecd9cfbb97b436ed9417f4962bc04264bcdb5e4 Mon Sep 17 00:00:00 2001
Fr
---
Anyone interested in it?
From eb0bb80c86c9539712b78cf8902d230e0c4e778e Mon Sep 17 00:00:00 2001
From: NalaGinrut
Date: Thu, 29 Dec 2011 17:25:03 +0800
Subject: [PATCH] ADD regexp-split
---
module/ice-9/regex.scm | 23 ++-
1 files changed, 22 insertions(+), 1 deleti
31 matches
Mail list logo