(1) -> i := 2; j := 2; [if i=j then 1 else 0 for j in 1..5]

   (1)  [1]
Type: List(PositiveInteger)
(2) -> i := 1; j := 2; [if i=j then 1 else 0 for j in 1..5]

   (2)  [0, 0, 0, 0, 0]
Type: List(NonNegativeInteger)

So the interpreter treats "[if i=j then 1 else 0 for j in 1..5]"
as "[if i=j then 1 else (0 for j in 1..5)]".

- Qian

On 11/3/22 16:19, Ralf Hemmecke wrote:
I don't know whether this is a bug or not. However, it took me some time to figure out where the problem was in an .input script.

(6) -> i := 2; j := 2; [if i=j then 1 else 0 for j in 1..5]

    (6)  [1]
                                  Type: List(PositiveInteger)
(7) -> i := 2; j := 2; [(if i=j then 1 else 0) for j in 1..5]

    (7)  [0, 1, 0, 0, 0]
                                  Type: List(NonNegativeInteger)


I am somewhat sure that it is a bug, because of the attached .spad file.
It behaves as expected and gives the output below, but behaves differently from what the interpreter does.

(17) -> z1 := [[f1(m,n) for n in 1..5] for m in 1..5];

                                              Type: List(List(List(Integer)))
(18) -> z2 := [[f2(m,n) for n in 1..5] for m in 1..5];

                                              Type: List(List(List(Integer)))
(19) -> (z1=z2)@Boolean

    (19)  true
                                                                Type: Boolean
(20) -> z1

    (20)
    [
      [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0],
       [1, 0, 0, 0, 0]]
      ,

      [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0],
       [0, 1, 0, 0, 0]]
      ,

      [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0],
       [0, 0, 1, 0, 0]]
      ,

      [[0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0],
       [0, 0, 0, 1, 0]]
      ,

      [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1],
       [0, 0, 0, 0, 1]]
      ]
                                              Type: List(List(List(Integer)))


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/aaf9a9c3-03d5-9057-699f-5dfc0d2813f3%40gmail.com.

Reply via email to