Skip to content
Snippets Groups Projects
Commit 8be5cd74 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Describe functions basic concepts

parent 37319592
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
......@@ -2047,18 +2047,46 @@ changes the output to
Obviously the behavior is the same using ~do...while~ or ~while~ loops.
** TODO Functions<<functions>>
** Functions<<functions>>
The ~pugs~ language allow the manipulation and definition of
functions. These are *mathematical functions* and are not functions as
functions in ~C++~. The functions in the ~pugs~ language are *not
subroutines*.
To be more precise, a function $f$ follows the following structure
\begin{align*}
\mbox{let }f:& X_1\times \cdots \times X_n \to Y_1\times \cdots \times Y_m,\\
& (x_1,\ldots,x_n)\mapsto (y_1,\ldots,y_m)=f(x_1,\ldots,x_n),
\end{align*}
where $n,m\in\mathbb{N}$, and where ${(X_i)}_{0\le i\le n}$ and ${(Y_i)}_{0\le
i\le m}$ are /simple/ types. Actually $X_1\times \cdots \times X_n$ and
$Y_1\times \cdots \times Y_m$ are /compound/ types.
Thus assuming that the function $f$ is defined in the language as ~f~,
one can use the following syntax to evaluate it. This is a
pseudo-code, real examples will follow. Assuming that ~(x1...,xn)~ has
been properly defined in ~X1*...*Xn~ one can write
#+BEGIN_SRC pugs :exports code
let (y1,...,ym):Y1*...*Ym, (y1,...,ym) = f(x1,...,xn);
#+END_SRC
or if ~(y1,...,ym)~ has already been defined in ~Y1*...*Ym~
#+BEGIN_SRC pugs :exports code
(y1,...,ym) = f(x1,...,xn);
#+END_SRC
*** Pure functions
*** Implicit type conversion for parameters and returned values
*** TODO Implicit type conversion for parameters and returned values
*** User-defined functions
*** TODO User-defined functions
*** TODO Builtin functions
** TODO modules
*** Builtin functions
[fn:pugs-def] ~pugs~: Parallel Unstructured Grid Solvers
[fn:MPI-def] ~MPI~: Message Passing Interface
[fn:DSL-def] ~DSL~: Domain Specific Language
** TODO modules
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment