Skip to content

Change map(f) behavior #48372

@jariji

Description

@jariji
julia> f() = 9
f (generic function with 1 method)

julia> map(f)
9

map is a variadic zipWith, so I think it should behave like zip.

I don't see a justification for making it call f once. f should be called once when the shortest data argument has length 1. But in zip() the shortest data argument is assumed to have infinite length. So the most consistent behavior is to yield an infinite stream of empty tuples. That is the current behavior of zip().

#47344 (comment):

Triage thinks that zip() should either be an infinite stream, or it should error.

I would think then map(f) should either yield an infinite stream of f() or throw an error.

For comparison, in Python, which has variadic map, it needs at least 1 data argument and throws an error otherwise.

This problem was pointed out on Discourse.

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