Coming from Scheme, Lisp, Haskell, lists are very important and used a lot. Is a Julia array the Julia version of a list, ie, use the same way as a list would be in Haskell or scheme?
I don’t know those languages, but I would say that a 1D array (also called Vector
) is similar to a list in python. The major difference from a python list that tripped me up when I first came from python is that arrays are typed, so if you have an array of integers, you can’t put in a string for example.
TLDR is yes.
That said they’re are a few alternatives to consider depending on your use case. The biggest 2 are Tuples and StaticArrays
For the sake of completeness, it should be added that however you can make arrays of type Any
, where you can put integers together with strings and whatever else you want, e.g. [1, "hello", false]
…
Julia arrays are like scheme vectors. The closest thing to a scheme pair (cons a b)
is the tuple (a,b)
(but they don’t get used in julia in the way you use cons all over the place in scheme)
A possibly important or possibly irrelevant difference:
Lists in Scheme and Haskell are immutable singularly linked lists.
Julia’s arrays are dynamic arrays. Specialness they have over e.g. C arrays is they are growable, and infact efficiently growable from both ends.
Julia arrays are more like Java’s, C++'s, scheme etc;s Vector, and like Python’s list.
Arrays and linked lists have very different performance characteristics.
and different APIs