{"id":13546339,"url":"https://github.com/guicho271828/trivia","last_synced_at":"2026-01-26T20:12:08.198Z","repository":{"id":28332059,"uuid":"31845198","full_name":"guicho271828/trivia","owner":"guicho271828","description":"Pattern Matcher Compatible with Optima","archived":false,"fork":false,"pushed_at":"2024-09-04T01:51:11.000Z","size":784,"stargazers_count":349,"open_issues_count":24,"forks_count":22,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-12-09T13:51:12.477Z","etag":null,"topics":["common-lisp","pattern-matching"],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guicho271828.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-03-08T09:55:58.000Z","updated_at":"2025-11-13T03:00:16.000Z","dependencies_parsed_at":"2022-08-07T13:15:43.180Z","dependency_job_id":"2d95a3c3-7f95-4120-b4f8-e2918c12b63b","html_url":"https://github.com/guicho271828/trivia","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/guicho271828/trivia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Ftrivia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Ftrivia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Ftrivia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Ftrivia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guicho271828","download_url":"https://codeload.github.com/guicho271828/trivia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guicho271828%2Ftrivia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28787174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common-lisp","pattern-matching"],"created_at":"2024-08-01T12:00:35.668Z","updated_at":"2026-01-26T20:12:08.182Z","avatar_url":"https://github.com/guicho271828.png","language":"Common Lisp","funding_links":[],"categories":["Common Lisp"],"sub_categories":[],"readme":"\n[[https://travis-ci.org/guicho271828/trivia][https://travis-ci.org/guicho271828/trivia.svg?branch=master]]\n\n+ news! new pattern: lambda-list pattern. Contributed by akssri\n+ news! new pattern: number-related patterns, e.g. \u003e, \u003c, =, \u003c= ... \n+ news! Inline pattern implemented ! : @, @@ ...\n+ news!(04/02/2016) Support for fare-quasiquote is now available. See =test/quasiquote= for the usage\n+ news!(04/22/2016) Added metabang-bind like macros =if-match=, =when-match=, =unless-match=, =let-match=, =let*-match=, =let-match1=\n+ news!(05/21/2016) Added support for minor implementations: CMU, ECL, CLISP, ABCL.\n+ news!(05/22/2016) Implemented =ARRAY=, =SIMPLE-ARRAY=, =ARRAY-ROW-MAJOR=, =ARRAY-ROW-MAJOR*= patterns! Multi-dimentional arrays are now more handy!\n+ news!(07/21/2016) Added =READ=, =LAST=, =SPLIT=, =SPLIT*= patterns! Parsing the string is more conveninent.\n+ news!(01/21/2017) Added =DYNAMIC= pattern! Careful use of this pattern can impact the performance sensitive code.\n+ news!(04/08/2017) Added a new contrib package =TRIVIA.CFFI= which provides =-\u003e= pattern ! Offers convenient access to foreign objects.\n+ news!(05/26/2018) Added =property!=, which only matches when the key is present in a plist.\n+ news!(09/06/2018) SPLIT symbol was exported from the =trivia.ppcre= package.\n+ news!(02/19/2019) Added =MEMBER= pattern. When the argument is a constant, it also adds type declaration.\n+ news!(04/24/2019) Improved the compilation of =GUARD= pattern. It no longer uses the internal hackery.\n+ news!(04/24/2019) *Balland2006 optimizer is now the default optimizer for the pattern compiler!*\n+ news!(04/28/2019) Added a =progv= pattern, which can dynamically alter the dynamic variable the value will be bound to.\n+ news!(05/08/2019) Now the optimizer can be specified in the lexical environment via =(declare (trivia:optimizer \u003cname\u003e))= (e.g. =(declare (trivia:optimizer :trivial))=). Implemented through cltl2 API.\n+ 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)\n+ *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.\n+ *news!(05/30/2021* Added support for [[https://github.com/slburson/fset][FSet]]. See [[test/fset.lisp][tests]] for how-to.\n\n* Trivia : Trivial Pattern Matching Compiler\n\nTrivia is a pattern matching compiler that is *compatible with Optima*.\nIt shares the same testing code with Optima and acts as a\ndrop-in replacement for 99% usage. For the basic usage, consult [[https://github.com/guicho271828/trivia/wiki][our wiki]].\n*Known differences between Optima and Trivia, which are bug, are [[https://github.com/guicho271828/trivia/wiki/Known-Differences][described here]] (7/31/2016)*\n\n#+BEGIN_SRC diff\n(defpackage :playwithit\n  (:use :cl \n-       :optima))\n+       :trivia))\n(in-package :playwithit)\n\n(match '(something #(0 1 2))\n  ((list a (vector 0 _ b))\n   (values a b)))\n;; --\u003e SOMETHING, 2\n#+END_SRC\n\nPatterns compiled with Trivia runs *[[https://github.com/guicho271828/trivia/wiki/Benchmarking-Results][faster than Optima]]*. \n\n| 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]] |\n|---------------+-----------+--------+--------------|\n| optima        | 11.5      | 39.8   | 82.5         |\n| trivia [1]    | *9.68*    | *37.4* | *1.57*       |\n\n[1]: trivia is using :balland2006 optimiizer\n\n... and Trivia is *more extensible*. In fact, Trivia's =defpattern= is able\nto implement all of [[https://github.com/m2ym/optima#constructor-pattern][unmodifiable, core pattern language]] in Optima within itself.\n\n#+BEGIN_SRC lisp\n(defpattern cons (a b)\n  (with-gensyms (it)\n    `(guard1 (,it :type cons) (consp ,it) (car ,it) ,a (cdr ,it) ,b)))\n#+END_SRC\n\nDetailed documentation is in [[https://github.com/guicho271828/trivia/wiki][github wiki]].\n\n* Dependency \u0026 Testing\n\n+ Level 0,1 : Alexandria only.\n+ Level 2 : Additionally, lisp-namespace and closer-mop.\n\nTo run the tests, =(asdf:test-system :trivia)= .\n\nTo run the benchmark, =(asdf:test-system :trivia.benchmark)=\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguicho271828%2Ftrivia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguicho271828%2Ftrivia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguicho271828%2Ftrivia/lists"}