Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 773518e35c
Fetching contributors…

Cannot retrieve contributors at this time

file 22 lines (20 sloc) 0.618 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
\begin{Exercise}[title={Integer ordering},difficulty=0]
\label{ex:ordering function}
\Question Write a function that returns its (two) parameters in the right,
numerical (ascending) order:\newline
\lstinline{f(7,2)} $\rightarrow$ \lstinline{2,7}\newline
\lstinline{f(2,7)} $\rightarrow$ \lstinline{2,7}\newline
\end{Exercise}

\begin{Answer}
\Question
Here we can use the multiple return values (section ``\titleref{sec:multiple return}'')
from Go:
\begin{lstlisting}
func order(a, b int) (int, int) {
        if a > b {
                return b,a
        }
        return a,b
}
\end{lstlisting}

\end{Answer}
Something went wrong with that request. Please try again.