Question: Difference between seq(f,n) and seq(f,1..n)?

If I understand right, the form seq(y, n) is equivalent to seq(y, 1 .. n, 1) (where the optional index variable is omitted), which produces a sequence of n occurrences of y. But how to explain the following output (of p1())? 

restart;

kernelopts(version)

`Maple 2023.0, X86 64 WINDOWS, Mar 06 2023, Build ID 1689885`

(1)

p0 := proc()
    local a := 1, b := 2;
    seq('assign(('a', 'b') = (a + 1, 2*b))', 1 .. 3);
    print(a, b)
end:

p1 := proc()
    local a := 1, b := 2;
    seq('assign(('a', 'b') = (a + 1, 2*b))', 3);
    print(a, b)
end:

p2 := proc()
    local a := 1, b := 2;
    'assign(('a', 'b') = (a + 1, 2*b))' $ 3;
    print(a, b)
end:

p3 := proc()
    local a := 1, b := 2;
    to 3 do
        assign(('a', 'b') = (a + 1, 2*b))
    od;
    print(a, b)
end:

p0()

p1()

p2()

p3()

4, 16

 

5, 32

 

4, 16

 

4, 16

(2)


Download singular_behaviour_of_`seq`.mw

Main code: 

p1 := proc()
    local a := 1, b := 2;
    seq('assign(('a', 'b') = (a + 1, 2*b))', 3);
    print(a, b)
end:
p1():
Please Wait...