k on a
> macro “regex-case”.Code attached.
> Comments on syntax appreciated. — Matt
>
> I was thinking the above expansion has some chance (if it lives in the regex
> module?) to memoize the make-regexp part during optimization.
I am going to try to optimize by using eval-wh
Matt Wette skribis:
> (regex-case str
>(("^([a-z]+)\\(([0-9]+)\\)$" v i)
> (list v i))
>(("^([a-z]+)$" v)
> (list v "1”)))
Sounds useful and convenient!
> (let ((t-292 (make-regexp "^([a-z]+)\\(([0-9]+)\\)$"))
> (t-
Matt Wette :
> [2] may be possible if it is supported by the Guile regexp library.
> But I’m not sure there is a clean way to do this, given that
> syntax-case bindings are lexical.
Additionally, you have a problem with the different regexp flags
(newline semantics, case-sensitivity etc).
Maybe
> On Feb 6, 2016, at 11:49 AM, Marko Rauhamaa wrote:
> Only two additions would be needed to make it better:
>
> [1] Python's named substrings: (?P...)
> (https://docs.python.org/3/library/re.html?highlight=regex#reg
> ular-expression-syntax>)
>
> [2] Seamless constant string concatena
k on a
> macro “regex-case”.Code attached.
> Comments on syntax appreciated. — Matt
I have added the else case and cleaned up the fold in rx-let. New code
attached, and echoed partial here:
;;; Copyright (C) 2016 Matthew R. Wette
;;;
;;; This library is free software; you can r
Matt Wette :
> Comments on syntax appreciated. — Matt
>
> === test
> (define str "foo")
>
> (regex-case str
>(("^([a-z]+)\\(([0-9]+)\\)$" v i)
> (list v i))
>(("^([a-z]+)$" v)
> (list v "1”)))
> On Feb 6, 2016, at 11:13 AM, Matt Wette wrote:
> If not a macro could be written to generate a match function which can
> memoize the make-regexp part.
> (define regex-matcher foo (( …)
> =>
> (define (let ((t-123 (make-regex )) …) (lambda (str) (cond
> ((regexp-exec t-123 str) ...
oops.
I have always missed the ease provided by Perl in throwing a string at a list
of regular expressions. I have thought it would be nice if the (ice-9 regex)
module would provide something comparable . So I started work on a macro
“regex-case”.Code attached.
Comments on syntax appreciated