\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{liebus} \pdfinfo{ /Title (elixir-ru-1.pdf) /Creator (Cheatography) /Author (liebus) /Subject (Elixir\_ru 1 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A020F0} \definecolor{LightBackground}{HTML}{F9F1FE} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Elixir\_ru 1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{liebus} via \textcolor{DarkBackground}{\uline{cheatography.com/180711/cs/37605/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}liebus \\ \uline{cheatography.com/liebus} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 9th March, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Числа}} \tn % Row 0 \SetRowColor{LightBackground} 3 & целое число \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0x1F & целое число \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} 3.0 & число с плавающей запятой \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Кортежи}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{1,2,3\} \# кортеж} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{elem(\{1, 2, 3\}, 0) \#=\textgreater{} 1} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Кортежи, хранятся в памяти \seqsplit{последовательно}. \newline Получить доступ к элементу кортежа мы можем с помощью функции {\bf{"elem"}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Атомы}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{:hello \# атом% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Атомы, которые являются нечисловыми константами. Они начинаются с символа `:`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Бинарные данные}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\textless{}\textless{}1,2,3\textgreater{}\textgreater{}% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Оператор " ? "}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{?a \#=\textgreater{} 97 \newline % Row Count 1 (+ 1) Оператор "?" возвращает целое число, \seqsplit{соответствующее} данному символу.% Row Count 4 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Карты (Maps)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Maps are key-value pairs:}} \newline % Row Count 1 (+ 1) genders = \%\{"david" =\textgreater{} "male", "gillian" =\textgreater{} "female"\} \newline % Row Count 3 (+ 2) genders{[}"david"{]} \#=\textgreater{} "male"% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Maps with atom keys:}} \newline genders = \%\{david: "male", gillian: "female"\} \newline genders.gillian \#=\textgreater{} "female"} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Строки}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{"hello"} & Elixir-строка (заключена в двойные кавычки) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{'hello'} & Erlang-строка (в одинарные кавычки) \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Все строки представлены в кодировке UTF-8: \newline "привет" \#=\textgreater{} "привет"} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Elixir-строки / Erlang-строки}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\textless{}\textless{}?a, ?b, ?c\textgreater{}\textgreater{} \#=\textgreater{} "abc" \newline % Row Count 1 (+ 1) {\bf{Elixir-строки являются бинарными данными}}% Row Count 3 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{[}?a, ?b, ?c{]} \#=\textgreater{} 'abc' \newline {\bf{Erlang-строка — это на самом деле список}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Конкатенация строк}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{"\textless{}\textgreater{}" - для объединения бин. данных (и Elixir-строк)}} \newline % Row Count 2 (+ 2) \textless{}\textless{}1,2,3\textgreater{}\textgreater{} \textless{}\textgreater{} \textless{}\textless{}4,5\textgreater{}\textgreater{} \#=\textgreater{} \textless{}\textless{}1,2,3,4,5\textgreater{}\textgreater{} \newline % Row Count 3 (+ 1) "hello " \textless{}\textgreater{} "world" \#=\textgreater{} "hello world"% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{"++" - для объединения списков (и Erlang-строк)}} \newline {[}1,2,3{]} ++ {[}4,5{]} \#=\textgreater{} {[}1,2,3,4,5{]} \newline 'hello ' ++ 'world' \#=\textgreater{} 'hello world'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{\seqsplit{Математические} операции}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{1 + 1 \# 10 - 5 \# 5 * 2 \# 10 / 2} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} div(10, 2) \#=\textgreater{} 5 & \seqsplit{целочисленное} деление \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} rem(10, 3) \#=\textgreater{} 1 & получение остатка от деления \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{В Elixir оператор "/" всегда возвращает число с плавающей запятой.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Relaxed boolean}} \tn % Row 0 \SetRowColor{LightBackground} 1 || true \#=\textgreater{} 1 & false \&\& 1 \#=\textgreater{} false \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} nil \&\& 20 \#=\textgreater{} nil & !true \#=\textgreater{} false \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{a || b}} gives true if a is true. Otherwise, it gives b. \newline {\bf{a \&\& b}} gives false if a is false. Otherwise, it gives b. \newline {\bf{!a}} gives false if a is true. Otherwise, it gives true.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Списки (Lists)}} \tn % Row 0 \SetRowColor{LightBackground} {[}1,2,3{]} & Списки, реализованы как связные списки \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{We can access the {\bf{head and tail}} of a list as follows: \newline {[}head | tail{]} = {[}1,2,3{]} \newline head \#=\textgreater{} 1 \newline tail \#=\textgreater{} {[}2,3{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Диапазоны (Ranges)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Ranges are represented as "start..end" \seqsplit{(включительно):} 1..10 \#=\textgreater{} 1..10% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{Сопоставление} с образцом применимо и для ranges: \newline lower..upper = 1..10 \newline {[}lower, upper{]} \#=\textgreater{} {[}1, 10{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.54747 cm} x{4.42953 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Операторы сравнения}} \tn % Row 0 \SetRowColor{LightBackground} a===b & strict equality (so 1 === 1.0 is false) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} a!==b & strict inequality (so 1 !== 1.0 is true) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} a==b & equality (so 1 == 1.0 is true) \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} a!=b & inequality (so 1 != 1.0 is false) \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} a\textgreater{}b & greater than the other (so 2\textgreater{}1 is true) \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} a\textgreater{}=b & greater than or equal (so 2\textgreater{}=1 is true) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} a\textless{}b & less than the other (so 1\textless{}2 is true) \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} a\textless{}=b & less than or equal (so 1\textless{}=2 is true) \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Elixir позволяет сравнивать значения разных типов: \newline {\bf{1 \textless{} :hello \#=\textgreater{} true}} \newline {\bf{Правило}}: число \textless{} атом \textless{} ссылка \textless{} функция \textless{} порт \textless{} процесс \textless{} кортеж \textless{} список \textless{} строка} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Булевые: `or`, `and`, `not`.}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{true and true \#=\textgreater{} true \newline % Row Count 1 (+ 1) false or true \#=\textgreater{} true \newline % Row Count 2 (+ 1) 1 and true \#=\textgreater{} ** (BadBooleanError)% Row Count 3 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{В качестве первого аргумента эти операторы ожидают булевое значение.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}