Closed magistere closed 11 years ago
It's intended to work, since Expr
s are just types, but I hadn't tested it. I'll take a look.
Thanks for the report. I just pushed a fix. Update and let me know if it works (or not) for you, or if you find any other issues.
Note that for this to work, you'll need to add ellipses to the args
variable inside of the call:
@match ex begin
Expr(:call, {:+, args...}, _) => args
_ => "None"
end
Cheers, Kevin
Kevin, thank you for quick fix and updating the package in repository. It works great now.
When I read package documentation on array matching, I've found one discrepancy in chapter "Extract first element, rest of vector". Now type of b
is SubArray, not Array.
julia> @match([1:4], [a,b...])
(1,[2,3,4])
julia> a
1
julia> b
3-element SubArray{Int32,1,Array{Int32,1},(Range1{Int32},)}:
2
3
4
I'd like to correct this myself, but I assume documentation sources are not on the GitHub.
Glad to hear it! The documentation sources are in the doc
directory.
And yes, the change from Array
to SubArray
was made a little while back, and I forgot to change the documentation. Now that you brought it to my attention, I'll get to it eventually, but a pull request would be quite welcome.
Done #5
Is it possible to match
Expr
expressions? The following script gives errorERROR: args not defined