unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* ANOUNCEMENT guile imatch - functional dynamic indexed matcher
@ 2016-10-31 19:14 Stefan Israelsson Tampe
  0 siblings, 0 replies; only message in thread
From: Stefan Israelsson Tampe @ 2016-10-31 19:14 UTC (permalink / raw)
  To: guile-user@gnu.org, guile-devel

[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]

This is an anouncement of a functional dynamic match library.

https://gitlab.com/tampe/guile-imatch

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)

[-- Attachment #2: Type: text/html, Size: 2631 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-31 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 19:14 ANOUNCEMENT guile imatch - functional dynamic indexed matcher Stefan Israelsson Tampe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).