All Projects → guicho271828 → Trivia

guicho271828 / Trivia

Licence: other
Pattern Matcher Compatible with Optima

Projects that are alternatives of or similar to Trivia

Qutuf
Qutuf (قُطُوْف): An Arabic Morphological analyzer and Part-Of-Speech tagger as an Expert System.
Stars: ✭ 84 (-60%)
Mutual labels:  pattern-matching
Motif
Scala-like pattern matching for Java 8
Stars: ✭ 149 (-29.05%)
Mutual labels:  pattern-matching
Akar
First-class patterns for Clojure. Made with love, functions, and just the right amount of syntax.
Stars: ✭ 176 (-16.19%)
Mutual labels:  pattern-matching
Matchpy
A library for pattern matching on symbolic expressions in Python.
Stars: ✭ 109 (-48.1%)
Mutual labels:  pattern-matching
Stumpy
STUMPY is a powerful and scalable Python library for modern time series analysis
Stars: ✭ 2,019 (+861.43%)
Mutual labels:  pattern-matching
Expat
Reusable, composable patterns across Elixir libraries
Stars: ✭ 157 (-25.24%)
Mutual labels:  pattern-matching
Patme
Elixir-style pattern matching for ruby methods
Stars: ✭ 75 (-64.29%)
Mutual labels:  pattern-matching
Hexraystoolbox
Hexrays Toolbox - Find code patterns within the Hexrays AST
Stars: ✭ 202 (-3.81%)
Mutual labels:  pattern-matching
Rosie Pattern Language
Rosie Pattern Language (RPL) and the Rosie Pattern Engine have MOVED!
Stars: ✭ 146 (-30.48%)
Mutual labels:  pattern-matching
Symja android library
☕️ Symja - computer algebra language & symbolic math library. A collection of popular algorithms implemented in pure Java.
Stars: ✭ 170 (-19.05%)
Mutual labels:  pattern-matching
Bem Xjst
bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
Stars: ✭ 115 (-45.24%)
Mutual labels:  pattern-matching
Z
Pattern Matching for Javascript
Stars: ✭ 1,693 (+706.19%)
Mutual labels:  pattern-matching
Egison Ruby
A Ruby gem for non-linear pattern-matching with backtracking
Stars: ✭ 159 (-24.29%)
Mutual labels:  pattern-matching
Pattern Matching Ts
⚡ Pattern Matching in Typescript
Stars: ✭ 107 (-49.05%)
Mutual labels:  pattern-matching
Symbolicutils.jl
Expression rewriting and simplification
Stars: ✭ 189 (-10%)
Mutual labels:  pattern-matching
Nanomatch
Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but without support for extended globs (extglobs), posix brackets or braces, and with complete Bash 4.3 wildcard support: ("*", "**", and "?").
Stars: ✭ 79 (-62.38%)
Mutual labels:  pattern-matching
Eval
Eval is a lightweight interpreter framework written in Swift, evaluating expressions at runtime
Stars: ✭ 157 (-25.24%)
Mutual labels:  pattern-matching
Zeallot
Variable assignment with zeal! (or multiple, unpacking, and destructuring assignment in R)
Stars: ✭ 204 (-2.86%)
Mutual labels:  pattern-matching
Gradoop
Distributed Graph Analytics with Apache Flink
Stars: ✭ 197 (-6.19%)
Mutual labels:  pattern-matching
Fpgo
Monad, Functional Programming features for Golang
Stars: ✭ 165 (-21.43%)
Mutual labels:  pattern-matching

[[https://travis-ci.org/guicho271828/trivia][https://travis-ci.org/guicho271828/trivia.svg?branch=master]]

  • news! new pattern: lambda-list pattern. Contributed by akssri
  • news! new pattern: number-related patterns, e.g. >, <, =, <= ...
  • news! Inline pattern implemented ! : @, @@ ...
  • news!(04/02/2016) Support for fare-quasiquote is now available. See =test/quasiquote= for the usage
  • news!(04/22/2016) Added metabang-bind like macros =if-match=, =when-match=, =unless-match=, =let-match=, =let*-match=, =let-match1=
  • news!(05/21/2016) Added support for minor implementations: CMU, ECL, CLISP, ABCL.
  • news!(05/22/2016) Implemented =ARRAY=, =SIMPLE-ARRAY=, =ARRAY-ROW-MAJOR=, =ARRAY-ROW-MAJOR*= patterns! Multi-dimentional arrays are now more handy!
  • news!(07/21/2016) Added =READ=, =LAST=, =SPLIT=, =SPLIT*= patterns! Parsing the string is more conveninent.
  • news!(01/21/2017) Added =DYNAMIC= pattern! Careful use of this pattern can impact the performance sensitive code.
  • news!(04/08/2017) Added a new contrib package =TRIVIA.CFFI= which provides =->= pattern ! Offers convenient access to foreign objects.
  • news!(05/26/2018) Added =property!=, which only matches when the key is present in a plist.
  • news!(09/06/2018) SPLIT symbol was exported from the =trivia.ppcre= package.
  • news!(02/19/2019) Added =MEMBER= pattern. When the argument is a constant, it also adds type declaration.
  • news!(04/24/2019) Improved the compilation of =GUARD= pattern. It no longer uses the internal hackery.
  • news!(04/24/2019) Balland2006 optimizer is now the default optimizer for the pattern compiler!
  • news!(04/28/2019) Added a =progv= pattern, which can dynamically alter the dynamic variable the value will be bound to.
  • news!(05/08/2019) Now the optimizer can be specified in the lexical environment via =(declare (trivia:optimizer ))= (e.g. =(declare (trivia:optimizer :trivial))=). Implemented through cltl2 API.
  • news!(10/11/2019) The OR1 consistency checking algorithm in Level 1 no longer takes the exponential runtime. Compilation of [[https://github.com/guicho271828/type-r][type-r]] library is now 10x faster! (patch from @pfdietz)
  • news!(01/01/2021) Added =HASH-TABLE-ENTRY=, =HASH-TABLE-ENTRIES= patterns, and corresponding =!= suffixed patterns for matching only if key is present in hash table.
  • Trivia : Trivial Pattern Matching Compiler

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 [[https://github.com/guicho271828/trivia/wiki][our wiki]]. Known differences between Optima and Trivia, which are bug, are [[https://github.com/guicho271828/trivia/wiki/Known-Differences][described here]] (7/31/2016)

#+BEGIN_SRC diff (defpackage :playwithit (:use :cl

  •   :optima))
    
  •   :trivia))
    

(in-package :playwithit)

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

Patterns compiled with Trivia runs [[https://github.com/guicho271828/trivia/wiki/Benchmarking-Results][faster than Optima]].

| runtime [sec] | [[https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L11][fibonacci]] | [[https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L40][gomoku]] | [[https://github.com/guicho271828/trivia/blob/master/bench/definitions.lisp#L214][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 [[https://github.com/m2ym/optima#constructor-pattern][unmodifiable, core pattern language]] in Optima within itself.

#+BEGIN_SRC lisp (defpattern cons (a b) (with-gensyms (it) `(guard1 (,it :type cons) (consp ,it) (car ,it) ,a (cdr ,it) ,b))) #+END_SRC

Detailed documentation is in [[https://github.com/guicho271828/trivia/wiki][github wiki]].

  • Dependency & Testing
  • Level 0,1 : Alexandria only.
  • Level 2 : Additionally, lisp-namespace and closer-mop.

To run the tests, =(asdf:test-system :trivia)= .

To run the benchmark, =(asdf:test-system :trivia.benchmark)=

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].