Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some updates + additions to the reference documentation #405

Closed
wants to merge 9 commits into from
18 changes: 6 additions & 12 deletions docs/reference/collections.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
Collections
===========

Disco has several built-in collection types (such as :doc:`lists
<list>`, :doc:`bags <bag>`, and :doc:`sets <set>`) which represent
collections of values. The pages linked below explain the different
ways to create and use collections, and the operations which can be
used on them.
Disco has several built-in :doc:`collection types <collection-types>`
(such as :doc:`lists <list>`, :doc:`bags <bag>`, and :doc:`sets <set>`)
which represent collections of values. The pages linked below explain
the different ways to create and use collections, and the operations
which can be used on them.

.. toctree::

list
string
set
bag
size
cp
ellipsis
collection-ops
set-ops
power
each
filter
comprehension
boom
map
Expand Down
41 changes: 20 additions & 21 deletions docs/reference/comprehension.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Comprehensions
==============

*Comprehension* notation can be used to describe :doc:`collections <collections>` such as
*Comprehension* notation can be used to describe collections such as
:doc:`sets <set>` or :doc:`lists <list>`. The general syntax for a
set comprehension is

Expand All @@ -15,8 +15,7 @@ some examples below; for the precise details, see the
`Details`_ section.

:doc:`List <list>` comprehensions are similar, but use square brackets
(``[``, ``]``) instead of curly braces (``{``, ``}``); :doc:`bag
<bag>` comprehensions use bag brackets (``⟅``, ``⟆``).
(``[``, ``]``) instead of curly braces (``{``, ``}``).

Examples
--------
Expand Down Expand Up @@ -97,37 +96,37 @@ Specification
.. note::

In case you are curious about the precise definition and are not
afraid of the details, the exact way that comprehensions
afraid of the details, the exact way that set comprehensions
work can be defined by the following three equations, making use of
the standard functions :doc:`each <each>` and ``$join``:

* ``{ e | } = e``
* ``{ e | x in xs, gs } = $join(each(\x. {e | gs}, xs))``
* ``{ e | g, gs } = {? { e | gs } if g, {} otherwise ?}``

``$join`` is not directly available to users, but can be accessed
by enabling the ``Primitives`` :doc:`extension <extensions>`. In
general, ``$join`` turns a thing-of-things into a thing
(list-of-lists into a list, bag-of-bags into a bag, *etc.*).
``$join`` is not directly available to users, but can be accessed
by enabling the ``Primitives`` :doc:`extension <extensions>`. In
general, ``$join`` turns a thing-of-things into a thing
(list-of-lists into a list, bag-of-bags into a bag, *etc.*).

- For lists, ``$join`` is equivalent to ``concat``.
- For lists, ``$join`` is equivalent to ``concat``.

::
::

Disco> $join [[1,2,3], [4], [5,6]]
[1, 2, 3, 4, 5, 6]
Disco> $join [[1,2,3], [4], [5,6]]
[1, 2, 3, 4, 5, 6]

- For sets, ``$join`` is equivalent to ``unions``.
- For sets, ``$join`` is equivalent to ``unions``.

::
::

Disco> $join {{1,2,3}, {2,3,4}, {3,5,6}}
{1, 2, 3, 4, 5, 6}
Disco> $join {{1,2,3}, {2,3,4}, {3,5,6}}
{1, 2, 3, 4, 5, 6}

- For bags, ``$join`` is equivalent to a straightforward
generalization of ``unions`` to work on bags instead of sets.
- For bags, ``$join`` is equivalent to a straightforward
generalization of ``unions`` to work on bags instead of sets.

::
::

Disco> $join (bag [bag [1,1,2], bag [1,1,2], bag [2,3,4], bag [2,5,6]])
⟅1 # 4, 2 # 4, 3, 4, 5, 6⟆
Disco> $join (bag [bag [1,1,2], bag [1,1,2], bag [2,3,4], bag [2,5,6]])
⟅1 # 4, 2 # 4, 3, 4, 5, 6⟆
Loading