Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
8be5cd74
Commit
8be5cd74
authored
3 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Describe functions basic concepts
parent
37319592
No related branches found
No related tags found
1 merge request
!145
git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/userdoc.org
+34
-6
34 additions, 6 deletions
doc/userdoc.org
with
34 additions
and
6 deletions
doc/userdoc.org
+
34
−
6
View file @
8be5cd74
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment