You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> @match :(5+5) begin
:($_ + $_) => true
_ => false
end
This should print true
Slightly more generally, the pattern
:(a + b) should match the expression :(a + b) and nothing else
:($_ + $_) should match any binary addition
:($a + $b) should match any binary addition, and define the pattern variables a and b.
:($$a + $$b) should match an addition, where the left-hand-side corresponds to the value of the local variable a and the right-hand-side corresponds to the value of the local variable b. One $ is for escaping from the enclosing :, and the other is for escaping the pattern syntax.
See also RelationalAI-oss/Rematch.jl#19
This should print
true
Slightly more generally, the pattern
:(a + b)
should match the expression:(a + b)
and nothing else:($_ + $_)
should match any binary addition:($a + $b)
should match any binary addition, and define the pattern variablesa
andb
.:($$a + $$b)
should match an addition, where the left-hand-side corresponds to the value of the local variablea
and the right-hand-side corresponds to the value of the local variableb
. One$
is for escaping from the enclosing:
, and the other is for escaping the pattern syntax.See also JuliaServices/Rematch2.jl#6
The text was updated successfully, but these errors were encountered: