{"id":13442714,"url":"https://github.com/tmccombs/mexpr","last_synced_at":"2026-02-27T18:03:08.238Z","repository":{"id":18801037,"uuid":"22015141","full_name":"tmccombs/mexpr","owner":"tmccombs","description":"Macro for Common Lisp to allow infix syntax for mathematicall expressions.","archived":false,"fork":false,"pushed_at":"2015-06-10T17:13:27.000Z","size":238,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-08T07:02:59.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/tmccombs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-19T17:29:47.000Z","updated_at":"2024-02-15T14:28:57.000Z","dependencies_parsed_at":"2022-09-02T08:50:56.271Z","dependency_job_id":null,"html_url":"https://github.com/tmccombs/mexpr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tmccombs/mexpr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fmexpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fmexpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fmexpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fmexpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmccombs","download_url":"https://codeload.github.com/tmccombs/mexpr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccombs%2Fmexpr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29907346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T17:28:36.873Z","status":"ssl_error","status_checked_at":"2026-02-27T17:28:20.970Z","response_time":57,"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":[],"created_at":"2024-07-31T03:01:49.571Z","updated_at":"2026-02-27T18:03:08.208Z","avatar_url":"https://github.com/tmccombs.png","language":"Common Lisp","funding_links":[],"categories":["Common Lisp"],"sub_categories":[],"readme":"mexpr\n=====\n\n[![Build Status](https://travis-ci.org/tmccombs/mexpr.svg)](https://travis-ci.org/tmccombs/mexpr)\n[![Join the chat at https://gitter.im/tmccombs/mexpr](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tmccombs/mexpr?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nMacro for Common Lisp to allow infix syntax for mathematical expressions.\n\nThe mexpr package contains the `infix` macro which converts infix expressions into Lisp S-Expressions.\n\nInstallation\n------------\nThe easiest way to install mexpr is with quicklisp.\n\n```lisp\n(ql:quickload :mexpr)\n```\n\nExamples\n--------\n\nThe following are examples of how the `infix` macro can be used:\n\n```lisp\nCL-USER\u003e (infix 3 + 4)\n7\nCL-USER\u003e (infix [ 3 + 4 ] * 5)\n35\nCL-USER (infix 3 + 4 * 5)\n23\nCL-USER\u003e (let ((x 0))\n\t   \t\t   (infix [ 4 + (1+ x) ] / (sqrt 4)))\n2.5\nCL-USER\u003e (infix 4 + 4 \u003c 7 or 2 \u003e 6 / 16)\nT\nCL-USER\u003e (infix 5 = 6)\nNIL\nCL-USER\u003e (infix 5 = 5)\nT\nCL-USER\u003e (infix 2 expt 5)\n32\n```\n\nYou can use `defop` to add new operators:\n\n```lisp\nCL-USER\u003e (defop union 10) ; use function name and precedence\nCL-USER\u003e (infix '(1 2) union '(2 3))\n(2 1 3 4)\nCL-USER\u003e (defop ++ 100 append) ; use operator symbol, precedence, and defition symbol\nCL-USER\u003e (infix '(1 2) ++ '(3 4))\n(1 2 3 4)\nCL-USER\u003e (defop p 110 (lambda (a b) (+ (* a a) (* b b)))) ; use lambda for definition\nCL-USER\u003e (infix 3 p 4)\n25\n```\n\nYou can use a reader macro to make it a little simpler:\n\n```lisp\nCL-USER\u003e (enable-infix-syntax) ; equivalent to (cl-syntax:use-syntax :mexpr)\nCL-USER\u003e #n(3 + 4 ** 2)\n19\n```\n\n### Notes:\n1. There always needs to be whitespace between operands and operators.\n2. Variables and other forms can be used as operands.\n3. Operators have an associated precedence. Higher precedence operators are performed first.\n4. Operators of equal precedence are evaluated left to right.\n5. [ and ] are used for grouping expressions (overriding precedence).\n\nUsage\n-----\n\nThe `mexpr` (or more verbose `bytecurry.mexpr`) package contains two main macros.\n\nThe `infix` macro parses it's arguments as an infix expression and produces the corresponding s-expression. Each argument\nis evaluated as one of the following forms:\n\n  - *Grouping*: The special forms `[` and `]` are used for grouping expressions. (Parentheses were already taken.)\n  - *Operator*: An operator is a symbol that has been registered using the `defop` macro. It represents a binary operation.\n  - *Operand*: An operand is any form which is not an operator. This means that normal prefix forms can be embedded in the infix expression.\n\nThe `infix` macro can detect some syntax errors, in which case it will create a `syntax-error` condition. The type of the\nsyntax error can be obtained with `syntax-error-type`. Unfortunately, at the moment some invalid forms simply produce strange results, such as a transposition of a operator and operand.\n\n---------------------------------------------------------------------------------\n\nThe `defop` macro can be used to define new operators. It takes two parameters, the first is the unquoted symbol of the\noperator, the second is the desired precedence of the operator [(see below for precedence table)](#precedence). The symbol\nshould correspond to a function or macro which can accept exactly two arguments (although it may have more optional arguments).\n\n---------------------------------------------------------------------------------\n\nThe function `infix-reader` is macro dispatch function which is available to the user to use in\nany reader macro he/she desires. The package also registers the \"#n\" dispatch with cl-syntax, so\nyou can enable syntax of the form `#n(\u003cexpr\u003e)` with `(cl-syntax:use-syntax :mexpr)`. Alternatively,\n`enable-infix-syntax` is a wrapper around `cl-syntax:use-syntax`.\n\nPrecedence\n----------\n\nUnlike prefix and postfix notations, infix notation uses operator precedence to determine the order of evaluation.\n`mexpr` uses a numeric precedence system, where the precedence of an operator is a positive integer. A higher number\ncorresponds to a higher precedence. The precedence of the default operators is given below:\n\n| Operator   | Precedence | Translation of `a \u003cop\u003e b`\n|:----------:|-----------:|:--------------------------\n| **         | 110        | `(expt a b)`\n| expt       | 110        | `(expt a b)`\n| *          | 100        | `(* a b)`\n| /          | 100        | `(/ a b)`\n| %          | 100        | `(mod a b)`\n| mod        | 100        | `(mod a b)`\n| rem        | 100        | `(rem a b)`\n| +          | 90         | `(+ a b)`\n| -          | 90         | `(- a b)`\n| ash        | 80         | `(ash a b)`\n| \u003c\u003c         | 80         | `(ash a b)`\n| \u003e\u003e         | 80         | `(ash a (- b))`\n| \u003c          | 70         | `(\u003c a b)`\n| \u003e          | 70         | `(\u003e a b)`\n| \u003c=         | 70         | `(\u003c= a b)`\n| \u003e=         | 70         | `(\u003e= a b)`\n| =          | 60         | `(= a b)`\n| /=         | 60         | `(/= a b)`\n| logand     | 50         | `(logand a b)`\n| \u0026          | 50         | `(logand a b)`\n| logxor     | 40         | `(logxor a b)`\n| ^          | 40         | `(logxor a b)`\n| logior     | 30         | `(logior a b)`\n| \u0026#92;\u0026#124;| 30         | `(logior a b)`\n| and        | 20         | `(and a b)`\n| or         | 10         | `(or a b)`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccombs%2Fmexpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmccombs%2Fmexpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccombs%2Fmexpr/lists"}