diff --git a/contents/computer_science.tex b/contents/computer_science.tex index 10cbfbc..e275273 100644 --- a/contents/computer_science.tex +++ b/contents/computer_science.tex @@ -12,7 +12,6 @@ \SetAlgoLined \SetNoFillComment \tcc{This is a comment} -\vspace{3mm} some code here\; $x \leftarrow 0$\; $y \leftarrow 0$\; @@ -35,16 +34,28 @@ $y \leftarrow 0$\; \caption{what} \end{algorithm} +\langsection{Exemple en Haskell}{Haskell example} +\begin{lstlisting}[language=Haskell] +fibonacci :: Int -> Int +fibonacci 0 = 0 +fibonacci 1 = 1 +fibonacci n = fibonacci (n - 1) + fibonacci (n - 2) +\end{lstlisting} + \langsection{Exemple en Python}{Python example} \begin{lstlisting}[language=Python] -def fnc(a, b): - return a + b +def fibonacci(n: int) -> int: + if n == 0 or n == 1: + return n + return fibonacci(n - 1) + fibonacci(n - 2) \end{lstlisting} \langsection{Exemple en C}{C example} \begin{lstlisting}[language=C] -int fnc(int a, int b){ - return a + b; +int fibonacci(const int n){ + if (n == 0 || n == 1) + return n; + return fibonacci(n - 1) + fibonacci(n - 2); } \end{lstlisting}