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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
54db8b5b
Commit
54db8b5b
authored
3 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add doc for access operator
parent
27ebe0ac
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
+21
-4
21 additions, 4 deletions
doc/userdoc.org
with
21 additions
and
4 deletions
doc/userdoc.org
+
21
−
4
View file @
54db8b5b
...
...
@@ -1269,6 +1269,8 @@ The ~pugs~ language allows the following tokens as unary operators
|----------+----------------------|
| ~++~ | increment operator |
| ~--~ | decrement operator |
|----------+----------------------|
| ~[]~ | access operator |
The ~not~, ~+~ and ~-~ operators apply to the *expression* on their right. ~++~
and ~--~ operators apply only to a *variable* that can be positioned
...
...
@@ -1283,11 +1285,11 @@ For basic types, when these operators are defined, they return a value
of the same type as the argument (except if the argument is a ~N~, then
the result is a ~Z~). These operators can be defined for high-level
types.
- The ~not~ operator is only defined for boolean values (~B~)
-
t
he ~-~ unary operator is defined for numeric basic types: ~B~,
- The ~not~ operator is only defined for boolean values (~B~)
.
-
T
he ~-~ unary operator is defined for numeric basic types: ~B~,
~N~, ~Z~, ~R~, ~R^1~, ~R^2~, ~R^3~, ~R^1x1~, ~R^2x2~ and ~R^3x3~. It is not defined
for ~string~ variables.
-
p
re and post increment operators, ~--~ and ~++~, are defined for all
-
P
re and post increment operators, ~--~ and ~++~, are defined for all
scalar basic types: ~N~, ~Z~ and ~R~. They are not defined for ~B~, ~R^1~,
~R^2~, ~R^3~, ~R^1x1~, ~R^2x2~, ~R^3x3~ and ~string~ variables.
...
...
@@ -1309,7 +1311,22 @@ produces the compilation error
Again, this is done to simplify the syntax and to avoid weird
constructions.
**** TODO Binary operators
- Access operators are only defined for small vectors ~R^d~ and small
matrices ~R^dxd~. To avoid use of uninitialized variables (or
partially uninitialized variables), these are ~read-only~ access
operators. Their syntax is the following.
#+NAME: Rd-Rdxd-access-operator
#+BEGIN_SRC pugs :exports both :results output
let x:R^2, x = (1,2);
let A:R^3x3, A = (1,2,3,4,5,6,7,8,9);
cout << "x[0] = " << x[0] << "\nx[1] = " << x[1] << "\n";
cout << "A[0,0] = " << A[0,0] << "\nA[2,1] = " << A[2,1] << "\n";
#+END_SRC
This code produces
#+results: Rd-Rdxd-access-operator
**** Binary operators
Syntax for binary operators follows again a classical structure if
~exp1~ and ~exp2~ denotes two expressions and if ~op~ denotes a binary
...
...
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