{ "info": { "author": "Brandon T. Willard", "author_email": "brandonwillard+cons@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: DFSG approved", "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "[![Build Status](https://travis-ci.org/brandonwillard/python-cons.svg?branch=master)](https://travis-ci.org/brandonwillard/python-cons) [![Coverage Status](https://coveralls.io/repos/github/brandonwillard/python-cons/badge.svg?branch=master)](https://coveralls.io/github/brandonwillard/python-cons?branch=master) [![PyPI](https://img.shields.io/pypi/v/cons)](https://pypi.org/project/cons/)\n\nPython `cons`\n==================\n\nAn implementation of [`cons`][cons] in Python.\n\nUsage and Design\n======================\n\nThe `cons` package attempts to emulate the semantics of Lisp/Scheme's `cons` as closely as possible while incorporating all the built-in Python sequence types:\n```python\n>>> from cons import cons, car, cdr\n>>> cons(1, [])\n[1]\n\n>>> cons(1, ())\n(1,)\n\n>>> cons(1, [2, 3])\n[1, 2, 3]\n```\n\nIn general, `cons` is designed to work with `collections.abc.Sequence` types.\n\nAccording to the `cons` package, `None` corresponds to the empty built-in `list`, as `nil` does in some Lisps:\n```python\n>>> cons(1, None)\n[1]\n```\n\nThe `cons` package follows Scheme-like semantics for empty sequences:\n```python\n>>> car([])\nTraceback (most recent call last):\n File \"\", line 1, in \nConsError: Not a cons pair\n\n>>> cdr([])\nTraceback (most recent call last):\n File \"\", line 1, in \nConsError: Not a cons pair\n\n```\n\nBy default, `str` types are not considered cons-pairs, although they are sequences:\n```python\n>>> cons(\"a\", \"string\")\nConsPair('a' 'a string')\n```\n\nThis setting can be overridden and other types can be similarly excluded from consideration by registering classes with the `abc`-based classes `MaybeCons` and `NonCons`.\n\n\nFeatures\n===========\n\n* Built-in support for the standard Python ordered sequence types: i.e. `list`, `tuple`, `Iterator`, `OrderedDict`.\n```python\n>>> from collections import OrderedDict\n>>> cons(('a', 1), OrderedDict())\nOrderedDict([('a', 1)])\n\n```\n* Existing `cons` behavior can be changed and support for new collections can be added through the generic functions `cons.core._car` and `cons.core._cdr`.\n* Built-in support for [`unification`][un].\n```python\n>>> from unification import unify, reify, var\n>>> unify([1, 2], cons(var('car'), var('cdr')), {})\n{~car: 1, ~cdr: [2]}\n\n>>> reify(cons(1, var('cdr')), {var('cdr'): [2, 3]})\n[1, 2, 3]\n\n>>> reify(cons(1, var('cdr')), {var('cdr'): None})\n[1]\n\n```\n\nInstallation\n================\n\n```python\npip install cons\n```\n\n\n[cons]: https://en.wikipedia.org/wiki/Cons\n[un]: https://github.com/mrocklin/unification\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brandonwillard/python-cons", "keywords": "", "license": "LGPL-3", "maintainer": "", "maintainer_email": "", "name": "cons", "package_url": "https://pypi.org/project/cons/", "platform": "any", "project_url": "https://pypi.org/project/cons/", "project_urls": { "Homepage": "https://github.com/brandonwillard/python-cons" }, "release_url": "https://pypi.org/project/cons/0.1.3/", "requires_dist": [ "toolz", "unification" ], "requires_python": ">=3.5", "summary": "An implementation of Lisp/Scheme-like cons in Python.", "version": "0.1.3" }, "last_serial": 5898138, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "115ae611cc9f508a04d6bf4c5320dd44", "sha256": "6632a7eff2311988e66199dd614263b06edfb338eec660082b2f4c7a2efc17c8" }, "downloads": -1, "filename": "cons-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "115ae611cc9f508a04d6bf4c5320dd44", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 4282, "upload_time": "2019-08-04T01:43:02", "url": "https://files.pythonhosted.org/packages/18/8b/21a9e8a454fad848a2bd49d46ee676d942b29d7d8bbfbc70e781a1232d2d/cons-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5a54c39231bd5e824b24bf6f2dd02276", "sha256": "a9a5d4ee628484febc13be39197be3b4efaa8b93db48ce2eb0dce8eba5f6b2ef" }, "downloads": -1, "filename": "cons-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5a54c39231bd5e824b24bf6f2dd02276", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4278, "upload_time": "2019-08-04T01:43:05", "url": "https://files.pythonhosted.org/packages/66/48/22dce5098bd691774edcba3f72f074ecf1be2c89b682f9634b93b4edb4c2/cons-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31ccefcdf1459b6c2afda957d3dfcb1b", "sha256": "e5c62cb330830cf3c776a70553b8797ef653812a096fe660e21cc87d4928896b" }, "downloads": -1, "filename": "cons-0.0.1.tar.gz", "has_sig": false, "md5_digest": "31ccefcdf1459b6c2afda957d3dfcb1b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4500, "upload_time": "2019-09-23T22:26:41", "url": "https://files.pythonhosted.org/packages/cb/f9/cbdbc5279df8fbdbb90218e16b20a51c11dbe4c8e5c27dca8a92ae6da4aa/cons-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "fa6c2a83d964475fcd79fb38413a3744", "sha256": "85f3e8670bc9127c468af6fb6ad70d80028e7dc5cddaa832071987c66579eb01" }, "downloads": -1, "filename": "cons-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fa6c2a83d964475fcd79fb38413a3744", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4315, "upload_time": "2019-09-23T22:46:24", "url": "https://files.pythonhosted.org/packages/8d/56/99bc2ce6d66af875138e9ae8c5b3ed95e352be398fbc62b78e17c3c8b3cd/cons-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "915d96ba9dd625bb07518c7dcaa8ea49", "sha256": "b79f2a248f02faf0918713d0a601809a884dead13d9ff298105976d0d52733fd" }, "downloads": -1, "filename": "cons-0.1.0.tar.gz", "has_sig": false, "md5_digest": "915d96ba9dd625bb07518c7dcaa8ea49", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4511, "upload_time": "2019-09-23T22:46:25", "url": "https://files.pythonhosted.org/packages/fb/c8/9b5e32949f1a67a953e06f1a5e0c99a4f4c85abe45638a61e9c12df6814b/cons-0.1.0.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "c59b7c9b1f388d8277420908cc7747f1", "sha256": "cacdb732c9899d02f10f6a6f486b08c8bde0f955d8b9a4c00e2ce697f97cae76" }, "downloads": -1, "filename": "cons-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c59b7c9b1f388d8277420908cc7747f1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 5180, "upload_time": "2019-09-24T02:50:56", "url": "https://files.pythonhosted.org/packages/18/d3/5f4903bf19a3cf46226e2d63bfe91d9bbe7010ba6ef7061d5de3d2f5eb30/cons-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d78b5819ecb5172d59ffb583ee4cb2b2", "sha256": "43c11d3e50c68cea886d7b675f25ca599e8f0e487f1d7d819e0e3000bde68f9f" }, "downloads": -1, "filename": "cons-0.1.2.tar.gz", "has_sig": false, "md5_digest": "d78b5819ecb5172d59ffb583ee4cb2b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 4926, "upload_time": "2019-09-24T02:50:57", "url": "https://files.pythonhosted.org/packages/11/26/878c8e098d479fd6c1b9a0edb264a04c3a4095c0949674eaebadea0dbef3/cons-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "152603bc45cd8c23d380fbfba5986213", "sha256": "a6a5062549f57cbdf2c9c13639ef5242e4aa331e3f53491f17ab05ab7527f572" }, "downloads": -1, "filename": "cons-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "152603bc45cd8c23d380fbfba5986213", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 5470, "upload_time": "2019-09-27T21:01:26", "url": "https://files.pythonhosted.org/packages/72/36/e069fd8378cea5c8c8eb6def56fa7fa840949a8dacb9aab85507fc514d2f/cons-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4f394013fa833bda843497b899b1a7b7", "sha256": "9d03a5ebf045300803c43de45e01c1a5fd9c71294f9a8ac986e2d7f2bdb05ee6" }, "downloads": -1, "filename": "cons-0.1.3.tar.gz", "has_sig": false, "md5_digest": "4f394013fa833bda843497b899b1a7b7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5283, "upload_time": "2019-09-27T21:01:27", "url": "https://files.pythonhosted.org/packages/b6/2b/3bb3752d9ec9b9dd2e804778857970fb2b0086bb2c0a9f4e05b149960b80/cons-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "152603bc45cd8c23d380fbfba5986213", "sha256": "a6a5062549f57cbdf2c9c13639ef5242e4aa331e3f53491f17ab05ab7527f572" }, "downloads": -1, "filename": "cons-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "152603bc45cd8c23d380fbfba5986213", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 5470, "upload_time": "2019-09-27T21:01:26", "url": "https://files.pythonhosted.org/packages/72/36/e069fd8378cea5c8c8eb6def56fa7fa840949a8dacb9aab85507fc514d2f/cons-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4f394013fa833bda843497b899b1a7b7", "sha256": "9d03a5ebf045300803c43de45e01c1a5fd9c71294f9a8ac986e2d7f2bdb05ee6" }, "downloads": -1, "filename": "cons-0.1.3.tar.gz", "has_sig": false, "md5_digest": "4f394013fa833bda843497b899b1a7b7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5283, "upload_time": "2019-09-27T21:01:27", "url": "https://files.pythonhosted.org/packages/b6/2b/3bb3752d9ec9b9dd2e804778857970fb2b0086bb2c0a9f4e05b149960b80/cons-0.1.3.tar.gz" } ] }