# Transpose of an array of Strings

**URL:** <https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431>\
**Category:** New to Julia\
**Tags:** strings, arrays\
**Created:** [May 29, 2020, 5:26pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431 "2020-05-29T17:26:45Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 31, 2020, 10:49pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/22 "2020-05-31T22:49:11Z")

</div>

I thought that collect(1:5) returned [1,2,3,4,5], which is different.  
1:5 is an iterator, so I do not see how == is possible. If you are, correct, I indeed  
Have a very serious misunderstanding.

Gordon

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [May 31, 2020, 10:51pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/23 "2020-05-31T22:51:31Z")

</div>

`1:5` is just a clever way of representing `[1, 2, 3, 4, 5]` without wasting memory. The point is that their behavior should be exactly the same.

This is the purpose of the AbstractVector type family.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [May 31, 2020, 10:58pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/24 "2020-05-31T22:58:32Z")

</div>

This post might help clarify things: [What is the difference between "==" and "===" comparison operators in Julia? - Stack Overflow](https://stackoverflow.com/a/38638838/12486544). It’s a bit out of date (I don’t think `===` is still an alias for `is`) but helps explain what `==` means.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [May 31, 2020, 10:59pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/25 "2020-05-31T22:59:36Z")

</div>

I do not want to sound rude but this is something you can check in half a minute in the REPL, there is no reason to write a comment questioning it and create more noise instead of checking it first.

```julia
julia> 1:5 == [1, 2, 3, 4, 5]
true

julia> typeof(1:5)
UnitRange{Int64}

julia> typeof([1, 2, 3, 4, 5])
Array{Int64,1}

julia> 1 == 1.0
true

```

Objects of different types can be considered equal. And an iterator/range is semantically a collection, even if it is represented by a fixed size object.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 31, 2020, 11:03pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/26 "2020-05-31T23:03:48Z")

</div>

I understand your point. However, notemthat you cannot domthe following g:

a= 1:5  
b = a[2]

However,

a= [1,2,3,4,5]  
b= a[2]

Is allowed. Therefore, their behavior is not the same. Would you suggest that they should be the same?

I would submitmthat 1:5 has the behavior of an iterator, which defines the equivalent of the next operator. Collect acts on 1:5 to return a vector. I do not know whether collect acts on more general iterators, go en that in principles, iterators can have infinite length.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [May 31, 2020, 11:07pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/27 "2020-05-31T23:07:49Z")

</div>

Thanks, and I apologize. I do not have a computer at my disposal. I am working from an iPad. I’m will drop it.

> I do not want to sound rude but this is something you can check in half a minute in the REPL, there is no reason to write a comment questioning it and create more noise instead of checking it first.

So I domhave a question: why not allow (1:5)[5] as an operation?

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [May 31, 2020, 11:11pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/28 "2020-05-31T23:11:58Z")

</div>

> [@erlebach](#):
>
> So I domhave a question: why not allow (1:5)[5] as an operation?

…

```julia
julia> (6:10)[3]
8

```

It is allowed.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [May 31, 2020, 11:13pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/29 "2020-05-31T23:13:40Z")

</div>

> [@erlebach](#):
>
> I understand your point. However, notemthat you cannot domthe following g:
> 
> a= 1:5  
> b = a[2]

Yes, you can. This works perfectly well. The thing you cannot do is mutate `a`, it’s an Immutable array. Ranges _are_ vectors. Just try

```julia
(1:5) isa AbstractVector 

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 1, 2020, 1:55am UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/30 "2020-06-01T01:55:54Z")

</div>

> [@erlebach](#):
>
> I am working from an iPad.

Maybe this can help you: [Julia Online Compiler & Interpreter - Replit](https://repl.it/languages/julia)

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [June 1, 2020, 10:51am UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/31 "2020-06-01T10:51:09Z")

</div>

🤦‍♂️

---

<div class="post-metadata">

**Author:** ![disadone](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/disadone/32/27089_2.png) [@disadone](https://discourse.julialang.org/u/disadone)\
**Post date:** [August 28, 2021, 12:07pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/32 "2021-08-28T12:07:05Z")

</div>

The solution:

> reshape(b,1,: )

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 28, 2021, 12:08pm UTC](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/33 "2021-08-28T12:08:48Z")

</div>

`permutedims` is probably easier

[Previous page](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431.md?page=1)
