Skip to content

Commit 591fb54

Browse files
committed
adding doctest and explanation about the use of assoc parameter
1 parent 1db0228 commit 591fb54

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mathics/builtin/layout.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ class Infix(Builtin):
175175
>> g[a, b] * c
176176
= c (a # b)
177177
178+
179+
Notice that $assoc$ controls when an element is going to be embraced by parenthesis, according to \
180+
the position in an outer 'Infix' expression. For example,
181+
182+
>> Infix[{a, Infix[{b,c},"#",300, Left]}, "@", 300, Right]
183+
= a@(b#c)
184+
185+
because the inner 'Infix' is tagger as 'Left' associative, disregarding the associativity of \
186+
the outer 'Infix' expression.
187+
178188
#> Format[r[items___]] := Infix[If[Length[{items}] > 1, {items}, {ab}], "~"]
179189
#> r[1, 2, 3]
180190
= 1 ~ 2 ~ 3

0 commit comments

Comments
 (0)