Skip to content
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

Export Base.vect #50895

Open
jariji opened this issue Aug 12, 2023 · 4 comments
Open

Export Base.vect #50895

jariji opened this issue Aug 12, 2023 · 4 comments
Labels
domain:docs This change adds or pertains to documentation

Comments

@jariji
Copy link
Contributor

jariji commented Aug 12, 2023

vect is a nice function just like tuple (albeit with an ugly abbreviated name). I want to use it more easily. Can we export it?

help?> Base.vect
  vect(X...)


  Create a Vector with element type computed from the promote_typeof of the argument, containing the argument list.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> a = Base.vect(UInt8(1), 2.5, 1//2)
  3-element Vector{Float64}:
   1.0
   2.5
   0.5
@adienes
Copy link
Contributor

adienes commented Aug 12, 2023

maybe if this is exported it should include documentation about when it would be appropriate to use over vec or collect or Vector

@brenhinkeller brenhinkeller added the domain:docs This change adds or pertains to documentation label Aug 12, 2023
@jishnub
Copy link
Contributor

jishnub commented Aug 23, 2023

Typically, one doesn't call vect directly, instead they use the literal vector construction syntax [1,2]. Do you intend to pass the function as an argument, possibly dispatching on it?

@DNF2
Copy link

DNF2 commented Aug 23, 2023

Isn't Base.vect basically the same as vcat?

@jariji
Copy link
Contributor Author

jariji commented Aug 23, 2023

vcat concatenates the arguments; vect wraps the arguments in a new vector.

julia> vcat([1], [2])
2-element Vector{Int64}:
 1
 2

julia> Base.vect([1], [2])
2-element Vector{Vector{Int64}}:
 [1]
 [2]

They do both accept scalars but the scalar method of vcat should be removed #34395.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

5 participants