Skip to content

Commit

Permalink
adding doctest and explanation about the use of assoc parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jul 29, 2023
1 parent 1db0228 commit 591fb54
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mathics/builtin/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ class Infix(Builtin):
>> g[a, b] * c
= c (a # b)
Notice that $assoc$ controls when an element is going to be embraced by parenthesis, according to \
the position in an outer 'Infix' expression. For example,
>> Infix[{a, Infix[{b,c},"#",300, Left]}, "@", 300, Right]
= a@(b#c)
because the inner 'Infix' is tagger as 'Left' associative, disregarding the associativity of \
the outer 'Infix' expression.
#> Format[r[items___]] := Infix[If[Length[{items}] > 1, {items}, {ab}], "~"]
#> r[1, 2, 3]
= 1 ~ 2 ~ 3
Expand Down

0 comments on commit 591fb54

Please sign in to comment.