Macaulay2 » Documentation
Packages » Macaulay2Doc :: continue
next | previous | forward | backward | up | index | toc

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 = /usr/local/share/Macaulay2/Macaulay2Doc/
     demo1.m2:11:6-14:7: --source code:
     g = y -> (
          c := f(y-1);
          d := f(y-2);
          c+d)
i8 : g 2
/usr/local/share/Macaulay2/Macaulay2Doc/demo1.m2:8:12:(3):[2]: error: division by zero
/usr/local/share/Macaulay2/Macaulay2Doc/demo1.m2:8:12:(3):[2]: --entering debugger (type help to see debugger commands)
/usr/local/share/Macaulay2/Macaulay2Doc/demo1.m2:
8:10-8:12: --source code:
     b := 1/x;
ii9 : code f

oo9 = /usr/local/share/Macaulay2/Macaulay2Doc/
      demo1.m2:6:7-9:7: --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.