@@ -746,45 +746,65 @@ to what is already available in Python, but support for using unpacking syntax
746746within comprehensions is rare. This section provides a brief summary of
747747support for similar syntax in a few other languages.
748748
749- Many languages that support comprehensions support double loops::
749+ Many languages that support comprehensions support double loops:
750+
751+ .. code :: python
750752
751753 # python
752754 [x for xs in [[1 ,2 ,3 ], [], [4 ,5 ]] for x in xs * 2 ]
753755
756+ .. code :: haskell
757+
754758 -- haskell
755759 [x | xs <- [[1,2,3], [], [4,5]], x <- xs ++ xs]
756760
761+ .. code :: julia
762+
757763 # julia
758764 [x for xs in [[1,2,3], [], [4,5]] for x in [xs; xs]]
759765
766+ .. code :: clojure
767+
760768 ; clojure
761769 (for [xs [[1 2 3] [] [4 5]] x (concat xs xs)] x)
762770
763771 Several other languages (even those without comprehensions) support these
764772operations via a built-in function/method to support flattening of nested
765- structures::
773+ structures:
774+
775+ .. code :: python
766776
767777 # python
768778 list (itertools.chain(* (xs* 2 for xs in [[1 ,2 ,3 ], [], [4 ,5 ]])))
769779
780+ .. code :: javascript
781+
770782 // Javascript
771783 [[1 ,2 ,3 ], [], [4 ,5 ]].flatMap (xs => [... xs, ... xs])
772784
785+ .. code :: haskell
786+
773787 -- haskell
774788 concat (map (\x -> x ++ x) [[1,2,3], [], [4,5]])
775789
790+ .. code :: ruby
791+
776792 # ruby
777793 [[1 , 2 , 3 ], [], [4 , 5 ]].flat_map {|e | e * 2 }
778794
779795 However, languages that support both comprehension and unpacking do not tend to
780796allow unpacking within a comprehension. For example, the following expression
781- in Julia currently leads to a syntax error::
797+ in Julia currently leads to a syntax error:
798+
799+ .. code :: julia
782800
783801 [xs... for xs in [[1,2,3], [], [4,5]]]
784802
785803 As one counterexample, support for a similar syntax was recently added to `Civet
786804<https://civet.dev/> `_. For example, the following is a valid comprehension in
787- Civet, making use of Javascript's ``... `` syntax for unpacking::
805+ Civet, making use of Javascript's ``... `` syntax for unpacking:
806+
807+ .. code :: javascript
788808
789809 for xs of [[1 ,2 ,3 ], [], [4 ,5 ]] then ... (xs++ xs)
790810
0 commit comments