On January 19, 2006 5:53 AM Fabio Stumbo wrote: ## if-then-else: what is wrong?I am having some problem with the if-then-else syntax in the .input files.
if i>0 then output("positive") else output("nonpositive") if i > 0 then output("positive") else output("nonpositive") if i > 0 then output("positive") else output("nonpositive") if i > 0 then output("positive") else output("nonpositive") if i > 0 then output("positive") else output("nonpositive") Well, I tried all of them, creating each time a blank r.input file with inside only: fricas i := 2
Type: PositiveInteger?followed by one of the "if...". The result is that the first two are ok, where as the other three give some syntax error (different each time). fricas for i in 2..2 repeat if i>0 then output("positive") else output("nonpositive") Type: Voidfricas for i in 2..2 repeat if i > 0 then output("positive") else output("nonpositive") Type: Voidfricas for i in 2..2 repeat if i > 0 then output("positive") else output("nonpositive") Type: Voidfricas for i in 2..2 repeat if i > 0 then output("positive") else output("nonpositive") Type: VoidThe ones above works OK. The following one looks like a bug... fricas for i in 2..2 repeat if i > 0 then output("positive") else output("nonpositive") fricas for i in 2..2 repeat if i > 0 then output(i) output("positive") else output(i) output("nonpositive") Type: Voidfricas i:=1.5
Type: Floatfricas a := if i > 0 then j := sin(i * pi()) exp(j + 1/j) else j := cos(i * 0.5 * pi()) log(abs(j)**5 + 1)
Type: Float
fricas test: (INT, Type: Voidfricas test(a, Type: VoidThen, fricas 4 rem -2
Type: NonNegativeInteger?fricas test(4, fricas Compiling function test with type (Integer,
Type: List(Integer)returns correctly '[1,1]?', but fricas 4 rem -3
Type: PositiveInteger?fricas test(4,
Type: List(Integer)or fricas 4 rem 2
Type: NonNegativeInteger?fricas test(4,
Type: List(Integer)returns wrongly '[0,1]?'. Actually the result is '[0, 0]?' which is correct. The same happens if I write fricas test: (INT, Type: Voidfricas test(a, Type: VoidWhy?
fricas )di op extendedEuclidean which is not too useful. Moreover, how can I just ask about, say, the second function extendedEuclidean? If I wanted to ask about the syntax of if-then-else, I would like to write something like: )? if or )ap if but nothing gives clues on how to use it. Thank you for all your help |