Skip to content

Superfluous collect in "Introduction to Julia" #2

@jlapeyre

Description

@jlapeyre

The example code following

data = collect(range(0.0, 5.0, 100))

works just as well with data = range(0.0, 5.0, 100), which does not materialize all of the elements. In the latter, the elements in data are generated as needed. This is idiomatic/recommended.

This same observation may apply in a couple of other places in the introduction.

If you are actually concerned about memory or performance in a particular instance it's worth benchmarking lazy vs. materialized array because the results might not be what you expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions