Re: [julia-users] Failing to update variable in while loop (Newbie)

2016-05-09 Thread Yichao Yu
On Mon, May 9, 2016 at 9:33 PM, David Enocksson  wrote:
> I have an issue in my program and I think it has to do with a nested while
> loop, related to the following situation:
>
> a = 1:1:10
> iter1 = 0
> iter2 = 0
>
> while iter1 < 10
>
>iter1 = iter1 + 1
>
>   while iter2 < 1
>
>  iter2 = iter2 + 1
>
>  print(a[iter1])

It should print a[1] a bunch of times here and never run the inner
loop again since the loop condition is false.

>
>   end
>
> end
>
>
> The problem is that a[iter1] is not updating. I want the result to be
>
>
> 1
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
>
> Any help would be very much appreciated.


[julia-users] Failing to update variable in while loop (Newbie)

2016-05-09 Thread David Enocksson
I have an issue in my program and I think it has to do with a nested while 
loop, related to the following situation:

a = 1:1:10
iter1 = 0
iter2 = 0

while iter1 < 10

   iter1 = iter1 + 1

  while iter2 < 1

 iter2 = iter2 + 1

 print(a[iter1])

  end

end


The problem is that a[iter1] is not updating. I want the result to be


1

2

3

4

5

6

7

8

9


Any help would be very much appreciated.