In Julia is there similar data structure like "list" in python?

452 views
Skip to first unread message

Jiakui Wang

unread,
Oct 31, 2013, 6:30:44 PM10/31/13
to julia...@googlegroups.com
I have to use something similar to "list" in python, but I can't find what to use in Julia.

Set() in Julia seems to be similar to "list" in python, but it seems to support push! and pop! only.

Any ideas?

Thanks!




Stefan Karpinski

unread,
Oct 31, 2013, 6:39:02 PM10/31/13
to Julia Users
What Python obtusely calls a list is actually an array. You can use Julia 1D arrays the way you would a Python "list".
Message has been deleted

Jiakui Wang

unread,
Oct 31, 2013, 6:44:18 PM10/31/13
to julia...@googlegroups.com
Thanks! Is there something similar to "enumerate()" in julia? It is very convenient!!!



On Thursday, October 31, 2013 5:41:48 PM UTC-5, John Lynch wrote:
I just use a single element cell.  Cell is basically an array of heterogeneous types.

So

list = {1,2,4,"this", "that", 5.12}

You can find a cheat sheet I'm building for Julia here.


John Lynch

unread,
Oct 31, 2013, 6:45:21 PM10/31/13
to julia...@googlegroups.com
I just use a single column cell.  Cell is basically an array of heterogeneous types.

So

    list = {1,2,4,"this", "that", 5.12}

You can find a cheat sheet I'm building for Julia here.

Then:

    push!(list,"the other")
    pop!(list)

Ivar Nesje

unread,
Oct 31, 2013, 6:46:11 PM10/31/13
to julia...@googlegroups.com
Does not enumerate work?

John Lynch

unread,
Oct 31, 2013, 6:46:17 PM10/31/13
to julia...@googlegroups.com
I just use a single column cell.  Cell is basically an array of heterogeneous types.

So

    list = {1,2,4,"this", "that", 5.12}
    push!(list,"the other")
    pop!(list)


Jiakui Wang

unread,
Oct 31, 2013, 6:51:31 PM10/31/13
to julia...@googlegroups.com
It works, thanks! I didn't find it on the Julia manual.



On Thursday, October 31, 2013 5:46:11 PM UTC-5, Ivar Nesje wrote:
Does not enumerate work?

Kevin Squire

unread,
Oct 31, 2013, 6:55:13 PM10/31/13
to julia...@googlegroups.com

andrew cooke

unread,
Oct 31, 2013, 9:04:55 PM10/31/13
to julia...@googlegroups.com
On Thursday, 31 October 2013 19:46:17 UTC-3, John Lynch wrote:
You can find a cheat sheet I'm building for Julia here.

when that's done, please put it on the main site.  very useful.  maybe it could be a little prettier, though ;o)
 

John Lynch

unread,
Oct 31, 2013, 9:48:30 PM10/31/13
to julia...@googlegroups.com
How do you add something to the main site. I am also most of the way through a less dense one for Gadfly plus a tutorial for Gadfly to complement Daniel's manual.

I modelled the sheet on a Python 2.5 one; so any thoughts on prettification or completeness would be welcome. I'll post a link to the latest one and the Gadfly one in the next 24 hours.

Ivar Nesje

unread,
Nov 1, 2013, 1:08:42 AM11/1/13
to julia...@googlegroups.com
Changing the homepage is done the same way as anything else. Submit a PR on github, or ask someone else to do it.
https://github.com/JuliaLang/julialang.github.com
Reply all
Reply to author
Forward
0 new messages