-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add each-function #79
Conversation
Codecov Report
@@ Coverage Diff @@
## master #79 +/- ##
==========================================
+ Coverage 73.85% 77.11% +3.26%
==========================================
Files 1 1
Lines 283 284 +1
==========================================
+ Hits 209 219 +10
+ Misses 74 65 -9
Continue to review full report at Codecov.
|
This reminds me of: help?> collect(::Type, ::Any)
collect(element_type, collection)
Return an Array with the given element type of all items in a collection or iterable. The result has the same shape and number of dimensions as collection.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> collect(Float64, 1:2:5)
3-element Array{Float64,1}:
1.0
3.0
5.0 Maybe this PR should do a |
It could be done, pretty easilly, but I'm not sure I agree that it should. I imagine it would add a bit of overhead, and it won't (without bigger changes) do what you expect in some cases:
will simply not recognize |
Okay, this is actually pretty good. I don't know about the performance impact, but the code ended up being pretty clean. Is it idiomatic to use try-catch like this in Julia? |
The failed codecov lines are ones where my editor accidentally corrected a pair of tabs to space indentation in code that isn't mine. I didn't know it would make a difference, and since it was consistent with the rest of the file I let it be. Sorry for my bad git discipline. |
Add function
each(ElementType, collection)
that returns an iterable witheltype<:ElementType
, even ifcollection
is an element, itself iterable, with anothereltype
. This makes it easier to write functions with arguments::Union{ String, Array{String} }
and similar.