Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi Folks,

Here are two instances of the distribute algorithm. Only the first gives the expected result. The only difference in the code is where the opening bracket is placed.

# ----------------------------------------------
# this works as expected

foo := A (
       B + C);

distribute (foo);

# ----------------------------------------------
# this fails to apply the "distribute" algorithm

bah := A
       (B + C);

distribute (bah);

Cheers, Leo

in Bug reports by (1.8k points)

Well spoted Leo!

I noticed that if you modify your expression to

bah := A *
       (B + C);

distribute (bah);

The distribute algorithm works as expected.

Interesting that the explicit * did the trick. I must admit it's not a common construction but it did pop up in some very long expressions with weird line breaks that I had been playing with.

1 Answer

+1 vote
 
Best answer

This has been reported a number of times now, so it's time to do something about it. Now fixed in github (2.4.5.9): a newline will act as a single whitespace character and hence turn your bah into bah: = A (B+C).

by (82.1k points)
selected by

Many thanks for the quick fix, much appreciated.

Excellent, thank you K.

...