Open gaurav-arya opened 1 year ago
Hello! I am interested in taking up this issue. Since its my first time can someone help me with what I should start with? I have already forked and cloned the repo.
@gaurav-arya, I tried some tweaking by myself and I feel that the correct way to do this would be:
union([i for i in 1:5])
This gives the following output:
5-element Vector{Int64}:
1
2
3
4
5
It will pass a Vector{Int64}
into the union
function. I don't know if the added functionality of not putting the square brackets in needed. Maybe the moderators can help with that. If it is really needed, I am ready to work on it but I might need some help
@udohjeremiah, does this need work?
@vmpyr, I assume you have been working on this and would love to follow up. If that's the case, thank you for your efforts so far, and I'm sure you've learned more about "Julia" on your way to your first working on this. As for the pull request (PR), I am not very familiar with it. I only added a label. So, I would advise you to provide your solution as a fix PR for this issue and then you can see what the community thinks of it.
I did try to understand the issue. For example, doing this with a string array also did the same thing:
julia> x = ["apple", "banana", "grapes"]
3-element Vector{String}:
"apple"
"banana"
"grapes"
julia> union(i for i in x)
3-element Vector{Any}:
"apple"
"banana"
"grapes"
julia> union([i for i in x])
3-element Vector{String}:
"apple"
"banana"
"grapes"
I think either the user can use the union([i for i in x])
syntax or we have to change the code to give a concrete type, the latter seems the way forward imo. I can work on this issue but I will need for digging around before that. I will make a WIP Pull Request soon as you have suggested.
The code
produces
The reason for the
Any
is likely because ofeltype(i for i in 1:5)
beingAny
, which probably makes sense. However, sinceunion
is eager, perhaps we should still expect the producedVector
to be concretely typed? For example, sinceunion
is called with only a single argument in the above case, the above is equivalent tounique(i for i in 1:5)
, or even justcollect(i for i in 1:5)
in the above case, both of which produce a concretely typed vector:Version info: