Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
% This file:
%   https://anggtwu.net/LATEX/2026defs-comprehensions.tex.html
%   https://anggtwu.net/LATEX/2026defs-comprehensions.tex
%           (find-angg "LATEX/2026defs-comprehensions.tex")
% Author: Eduardo Ochs <eduardoochs@gmail.com>
% Version: 2026feb15
%
% Used by:
%   (bafp 6 "comprehensions")
%   (bafa   "comprehensions")
%   (wld2026p 12 "set-comprehensions")
%   (wld2026a    "set-comprehensions")
%   (2026setcomprp 1 "introduction")
%   (2026setcompra   "introduction")
%
% The comprehension boxes are generated by:
%   (find-angg "LUA/Comprehensions1.lua" "Comprehension-tests")
%   (find-angg "LUA/Comprehensions2.lua" "Comprehension-runcmds-tests")
%
% «.vbtsmash»		(to "vbtsmash")
% «.picturedots»	(to "picturedots")
% «.comprehensionbox»	(to "comprehensionbox")
% «.undtext»		(to "undtext")
% «.three-examples»	(to "three-examples")


% «vbtsmash»  (to ".vbtsmash")
% See: (find-LATEX "edrx21.sty" "setdepthto")
\def\vbtsmash#1{\nodepthnoheight{\vbtc{#1}}}


% «picturedots»  (to ".picturedots")
%L dofile "PictureDots1.lua"          -- (find-LATEX "PictureDots1.lua")
\pu
\def\picturedots(#1,#2)(#3,#4)#5{\saexpr{
    PictureDots.from(#1,#2, #3,#4, "#5"):topict():pgat("patc")
  }}

% «comprehensionbox»  (to ".comprehensionbox")
% For: (find-angg "LUA/Comprehensions1.lua" "Comprehension-tests")
\def\comprehensionbox#1{\vbtbgbox{\ensuremath{\mat{#1}}}}
\def\V{\mathbf{V}}
\def\F{\mathbf{F}}
\def\Stop{\omit\vrule\phantom{$\scriptstyle($}\hss}
\def\Stop{\omit|\hss}
\def\HLine{\hline\\[0pt]}
\def\HLine{\hline}

% «undtext»  (to ".undtext")
\def\undtext#1#2{\underbrace{\mathstrut#1}_{\mathstrut\text{#2}}}
\def\ug#1{\undtext{#1}{gen}}
\def\uf#1{\undtext{#1}{filt}}
\def\ue#1{\undtext{#1}{expr}}

% «three-examples»  (to ".three-examples")

%V for a=2,4 do
%V   print(10*a)
%V end
%L
%L defvbt "compr 10*a"
\pu

%V for a=2,4 do
%V   if a^2<10 then
%V     print(a)
%V   end
%V end
%L
%L defvbt "compr a^2<10"
\pu

%V for x=1,6 do
%V   for y=6,6-x do
%V     print(x,y)
%V   end
%V end
%L
%L defvbt "compr triangle"
\pu

\sa {compr 10*a}      { \setofst     {10a}      {a∈\{2,3,4\}}             }
\sa {compr 10*a u}    { \setofst {\ue{10a}} {\ug{a∈\{2,3,4\}}}            }
\sa {compr 10*a u;}   { \setofsc            {\ug{a∈\{2,3,4\}}} {\ue{10a}} }

\sa {compr a^2<10}    { \setofst     {a∈\{2,3,4\}}      {a^2<10}           }
\sa {compr a^2<10 u}  { \setofst {\ug{a∈\{2,3,4\}}} {\uf{a^2<10}}          }
\sa {compr a^2<10 u;} { \setofsc {\ug{a∈\{2,3,4\}},  \uf{a^2<10}} {\ue{a}} }

\sa {compr triangle;} {
  \setofsc {    x∈\{1,\ldots,5\},
                y∈\{x,\ldots,6-x\}
           }
           {   (x,y) }
  }

\sa {compr triangle u;} {
  \setofsc {\ug{x∈\{1,\ldots,5\}},
            \ug{y∈\{x,\ldots,6-x\}}
           }
           {\ue{(x,y)}}
  }

\sa {compr triangle dots} {
  \picturedots(0,0)(6,6){ 1,1 1,2 1,3 1,4 1,5 2,2 2,3 2,4 3,3 }
  }

\sa {compr triangle dots wrong} {
  \picturedots(0,0)(6,6){ 1,1 1,2 1,3 1,4 1,5 2,2 2,3 2,4 3,3 4,3 }
  }

\sa {compr triangle tree thin} {
  \comprehensionbox{
    x & y & (x,y) \\\HLine
    1 & 1 & (1,1) \\
      & 2 & (1,2) \\
      & 3 & (1,3) \\
      & 4 & (1,4) \\
      & 5 & (1,5) \\
    2 & 2 & (2,2) \\
      & 3 & (2,3) \\
      & 4 & (2,4) \\
    3 & 3 & (3,3) \\
    4 & \Stop \\
    5 & \Stop \\
  }}

\sa {compr triangle tree wide} {
  \comprehensionbox{
    x & 6-x & \{x,\ldots,6-x\} & y & (x,y) \\\HLine
    1 & 5 & \{1,2,3,4,5\} & 1 & (1,1) \\
      &   &               & 2 & (1,2) \\
      &   &               & 3 & (1,3) \\
      &   &               & 4 & (1,4) \\
      &   &               & 5 & (1,5) \\
    2 & 4 & \{2,3,4\} & 2 & (2,2) \\
      &   &           & 3 & (2,3) \\
      &   &           & 4 & (2,4) \\
    3 & 3 & \{3\} & 3 & (3,3) \\
    4 & 2 & \{\} & \Stop \\
    5 & 1 & \{\} & \Stop \\
  }}




% Local Variables:
% coding:  utf-8-unix
% End: