next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: continue

continue -- continue with the next iteration of a loop

Synopsis

Description

i1 : for i from 1 to 4 list (continue 4; print ho) do print hi
hi
hi
hi
hi

o1 = {4, 4, 4, 4}

o1 : List
i2 : for i from 1 to 4 list (continue ; 14) do print hi
hi
hi
hi
hi

o2 = {}

o2 : List
i3 : for i from 1 to 4 list 14 do print hi
hi
hi
hi
hi

o3 = {14, 14, 14, 14}

o3 : List
i4 : i = 0 ; while i < 10 do ( i = i+1; if i == 5 then continue ; print i )
1
2
3
4
6
7
8
9
10

Here is an example of the use of continue in the debugger after altering a value so continuation will not cause the error to recur.

i6 : load "Macaulay2Doc/demo1.m2"
i7 : code g

o7 = /home2/dan/src/M2/M2/Macaulay2/packages/Macaulay2Doc/demo1.m2:11:7-14:8: --source code:
     g = y -> (
          c := f(y-1);
          d := f(y-2);
          c+d)
i8 : g 2
/home2/dan/src/M2/M2/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: error: division by zero
/home2/dan/src/M2/M2/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:12:(3):[2]: --entering debugger (type help to see debugger commands)
/home2/dan/src/M2/M2/Macaulay2/packages/Macaulay2Doc/demo1.m2:8:11-8:13: --source code:
     b := 1/x;
ii9 : code f

oo9 = /home2/dan/src/M2/M2/Macaulay2/packages/Macaulay2Doc/demo1.m2:6:8-9:8: --source code:
      f := x -> (
           a := "hi there";
           b := 1/x;
           b+1)
ii10 : x

oo10 = 0
ii11 : x = 11

oo11 = 11
ii12 : continue

      34
o12 = --
      11

o12 : QQ

For the programmer

The object continue is a keyword.