You are right, this does not hold anymore (apparently). The docs should be
adjusted? I wasn't aware of this exception of the pile rule.
--- chapter 5.3
*The usual rules for piles are suspended for conditional expressions. In
.input files,* the then and else keywords can begin in the same column as
the corresponding if but may also appear to the right. Each of the
following styles of writing if-then-else expressions is acceptable:
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")
---
In function bodies it's ok.
f(x) ==
if x > 0 then
return 1
else
return 0
On Sunday, 5 January 2025 at 10:47:47 UTC+1 Kurt Pagani wrote:
> Use line continuation (_) or correct indentation (see last item)
>
> if 1 > 0 then output("positive") else output("nonpositive")
>
> if 1 > 0 then output("positive") _
> else output("nonpositive")
>
> if 1 > 0 then output("positive") _
> else output("nonpositive")
>
> if 1 > 0 _
> then output("positive") _
> else output("nonpositive") _
>
> if 1 > 0 _
> then output("positive") _
> else output("nonpositive")
>
>
> if 1 > 0 then
> output("positive") else
> output("nonpositive")
>
>
> --
>
>
> if 1 > 0 then output("positive") else output("nonpositive")
>
> positive
> Type:
> Void
>
> if 1 > 0 then output("positive") _
>
> else output("nonpositive")
>
> positive
> Type:
> Void
>
> if 1 > 0 then output("positive") _
>
> else output("nonpositive")
>
> positive
> Type:
> Void
>
> if 1 > 0 _
> then output("positive") _
> else output("nonpositive") _
>
> positive
> Type:
> Void
>
> if 1 > 0 _
> then output("positive") _
>
> else output("nonpositive")
>
> positive
> Type:
> Void
>
>
>
> if 1 > 0 then
> output("positive") else
> output("nonpositive")
>
> positive
> Type:
> Void
> (12) ->
>
>
> On Saturday, 4 January 2025 at 19:08:08 UTC+1 Sid Andal wrote:
>
>> The file test.input contains the following lines from the manual
>> on acceptable (indented) if-then-else expressions:
>>
>> cat test.input:
>>
>> if 1 > 0 then output("positive") else output("nonpositive")
>>
>> if 1 > 0 then output("positive")
>> else output("nonpositive")
>>
>> if 1 > 0 then output("positive")
>> else output("nonpositive")
>>
>> if 1 > 0
>> then output("positive")
>> else output("nonpositive")
>>
>> if i > 0
>> then output("positive")
>> else output("nonpositive")
>>
>>
>> Except for the first one-liner, the remaining ones give syntax errors:
>>
>>
>> (1) -> )r test
>> if 1 > 0 then output("positive") else output("nonpositive")
>>
>> positive
>>
>> if 1 > 0 then output("positive")
>>
>> positive
>> else output("nonpositive")
>>
>> Line 4: else output("nonpositive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>>
>> if 1 > 0 then output("positive")
>>
>> positive
>> else output("nonpositive")
>>
>> Line 7: else output("nonpositive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>>
>> if 1 > 0
>>
>> Line 8:
>> Line 9: if 1 > 0
>> .......A
>> Error A: syntax error at top level
>> Error A: Possibly missing a then
>> 2 error(s) parsing
>>
>> Continuing to read the file...
>>
>> then output("positive")
>>
>> Line 10: then output("positive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>> else output("nonpositive")
>>
>> Line 11: else output("nonpositive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>>
>> if 1 > 0
>>
>> Line 12:
>> Line 13: if 1 > 0
>> .......A
>> Error A: syntax error at top level
>> Error A: Possibly missing a then
>> 2 error(s) parsing
>>
>> Continuing to read the file...
>>
>> then output("positive")
>>
>> Line 14: then output("positive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>> else output("nonpositive")
>>
>> Line 15: else output("nonpositive")
>> A
>> Error A: Improper syntax.
>> 1 error(s) parsing
>>
>> Continuing to read the file...
>>
>> (4) ->
>>
>> Thanks,
>> SWA
>>
>
--
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 visit
https://groups.google.com/d/msgid/fricas-devel/9f61c924-0d3f-43cf-bca0-1c177f3632f8n%40googlegroups.com.