Skip to content

Commit

Permalink
Update loops example
Browse files Browse the repository at this point in the history
  • Loading branch information
asynchroza committed Nov 19, 2023
1 parent 72288c3 commit 850762a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions examples/loops.nula
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ for (def a = 5; a < 100; a * 2) {
def referred = 1000;

# You're not required to dereference references in the initialization header
for (def a = &referred; a > 0; a / 2) {
for (def a = &referred; a < 10000; a * 2) {

# but you're required to do so in the loop's body
# a = *a / 2;

# TODO: Fix bug - happens only when using division when initializing the increment and addition in the body of the loop
a = *a + 2;
# but you need to do dereference in the body
a = *a + *a / 4; # NB: you're not required to dereference the identifier when assigning to it

# Remember? Dereferencing is not required when logging
log("The value of the referred variable is: ", referred);
log("The value of the referred variable is: ", a);
}

log(referred);
# 'referred' should reflect the changes applied to the reference 'a'
log(referred);

0 comments on commit 850762a

Please sign in to comment.