File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
assets/images/functions/Enum
content/en/functions/Enum Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ \matrix [list=a] {
2+ \node [index=1]; &
3+ \node [index=2]; &
4+ \node [elements between]; &
5+ \node [index=n]; \\
6+ };
7+
8+ \foreach \i in {1,2,n}{
9+ \node (fun\i ) [fun, below=.5 of a\i .south];
10+ \draw [->] (a\i .south) -- (fun\i .in);
11+ \draw [->] (fun\i .out) -- +(0, -.5)
12+ node (b\i ) [below] {$ b_{\i }$ };
13+ };
14+
15+
16+
17+ \draw [brace] (bn.south east) -- (b1.south west);
18+
19+ \draw [->] (last brace) -- +(0, -1)
20+ node [below]
21+ {$ b_1 + b_2 + \dots + b_n = \displaystyle\sum _{i=1}^n b_i$ };
22+
Original file line number Diff line number Diff line change 1+ ---
2+ title : sum_by/2
3+ url : Enum/sum_by/2
4+ ---
5+
6+ Maps and computes the sum of the given ` enumerable ` in one pass.
7+
8+ Raises ` ArithmeticError ` if ` fun ` returns a non-numeric value.
9+
10+ {{< figure src="images/functions/Enum/sum_by-2.svg" >}}
Original file line number Diff line number Diff line change 364364 defmodule Enum do
365365 def sum(enumerable)
366366 end
367+ - name : sum_by/2
368+ signature : |
369+ defmodule Enum do
370+ def sum_by(enumerable, fun)
371+ end
367372 - name : take/2
368373 signature : |
369374 defmodule Enum do
You can’t perform that action at this time.
0 commit comments