diff --git a/docs/reference/collections.rst b/docs/reference/collections.rst index f8a17bb6..b76caeb5 100644 --- a/docs/reference/collections.rst +++ b/docs/reference/collections.rst @@ -1,25 +1,19 @@ Collections =========== -Disco has several built-in collection types (such as :doc:`lists -`, :doc:`bags `, and :doc:`sets `) 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 ` +(such as :doc:`lists `, :doc:`bags `, and :doc:`sets `) +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 diff --git a/docs/reference/comprehension.rst b/docs/reference/comprehension.rst index 941bebb4..24d72088 100644 --- a/docs/reference/comprehension.rst +++ b/docs/reference/comprehension.rst @@ -1,7 +1,7 @@ Comprehensions ============== -*Comprehension* notation can be used to describe :doc:`collections ` such as +*Comprehension* notation can be used to describe collections such as :doc:`sets ` or :doc:`lists `. The general syntax for a set comprehension is @@ -15,8 +15,7 @@ some examples below; for the precise details, see the `Details`_ section. :doc:`List ` comprehensions are similar, but use square brackets -(``[``, ``]``) instead of curly braces (``{``, ``}``); :doc:`bag -` comprehensions use bag brackets (``⟅``, ``⟆``). +(``[``, ``]``) instead of curly braces (``{``, ``}``). Examples -------- @@ -97,7 +96,7 @@ 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 ` and ``$join``: @@ -105,29 +104,29 @@ Specification * ``{ 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 `. 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 `. 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⟆