This is an anouncement of a functional dynamic match library.
If you know of a similar library let me know, atm it is not that advanced but according to any request I'm able to take this as far as it can possibly go. This is an initial anouncement and it is pre alpha compillable and fun.
Here is an exerpt of the README:
---------------------------------------------
USAGE:
1/ put this dir in guile's search path
2/ fire up guile and import ity through
(use-modules (ice-9 imatch))
-------------------------------------------------------------------------------
A functional matcher and indexed matcher for lare matchers use the index
matcher imatch else for small problem the sequential dmatch
pattern a symbol ?a represents a variable and the rest is atoms list and
vectors.
The emty imatch is imatch-null, the empty dmatch is dmatch-null. We can add a matcher in front of the structure or at the end. The api for this is
dmatch <- (append-dmatch pat lambda dmatch)
dmatch <- (prepend-dmatch pat lambda dmatch)
imatch <- (append-dmatch pat lambda imatch)
imatch <- (prepend-dmatch pat lambda imatch)
lambd will at a match be fed with the variables defined in a depth first search
in the pattern. To apply the match use it as
(dmatch x dmatch-data #:optional (fail (lambda () (error "dmatch failed"))))
(imatch x imatch-data #:optional (fail (lambda () (error "imatch failed"))))
------------------------------------------------------------------------------
Example:
(define m1 (prepend-imatch '(1 2) (lambda () 'a) imatch-null))
(define m2 (append-imatch '(?a 2) (lambda (?a) (list 'b ?a)) m1))
> (imatch '(1 2) m2)
'a
> (imatch '(9 2) m2)
'(b 9)