(github.com) guicho271828/trivia: Pattern Matcher Compatible with Optima

ROAM_REFS: https://github.com/guicho271828/trivia

Trivia is a pattern matching compiler that is compatible with Optima. It shares the same testing code with Optima and acts as a drop-in replacement for 99% usage. For the basic usage, consult our wiki. Known differences between Optima and Trivia, which are bug, are described here (7/31/2016)

(defpackage :playwithit
  (:use :cl
-       :optima))
+       :trivia))
(in-package :playwithit)

(match '(something #(0 1 2))
  ((list a (vector 0 _ b))
   (values a b)))
;; --> SOMETHING, 2

Patterns compiled with Trivia runs faster than Optima.

runtime [sec] fibonacci gomoku string-match
optima 11.5 39.8 82.5
trivia [1] 9.68 37.4 1.57

[1]: trivia is using :balland2006 optimiizer

… and Trivia is more extensible. In fact, Trivia's

defpattern
is able to implement all of unmodifiable, core pattern language in Optima within itself.

(defpattern cons (a b)
  (with-gensyms (it)
    `(guard1 (,it :type cons) (consp ,it) (car ,it) ,a (cdr ,it) ,b)))

Detailed documentation is in github wiki.

Local Graph

org-roam 607fd56b-7a94-4a30-9489-a66ec3e9a0a9 (github.com) guicho271828/trivia: Pat... //github.com/guicho271828/trivia/wiki https://github.com/guicho271828/trivia/wiki 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/wiki //github.com/guicho271828/trivia/wiki/Known-Differences https://github.com/guicho271828/trivia/wiki/Known-Differences 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/wiki/Known-Differences //github.com/guicho271828/trivia/wiki/Benchmarking-Results https://github.com/guicho271828/trivia/wiki/Benchmarking-Results 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/wiki/Benchmarking-Results //github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L11 https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L11 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L11 //github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L40 https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L40 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L40 //github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L214 https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L214 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L214 //github.com/m2ym/optima#constructor-pattern https://github.com/m2ym/optima#constructor-pattern 607fd56b-7a94-4a30-9489-a66ec3e9a0a9->//github.com/m2ym/optima#constructor-pattern 2a07e4ea-610b-4c9a-bb84-d961fb2450e5 Code and Coffee Book Club 2a07e4ea-610b-4c9a-bb84-d961fb2450e5->607fd56b-7a94-4a30-9489-a66ec3e9a0a9