Skip to content

Argument matching in partial() doesn't happen for primitive functions #360

@yutannihilation

Description

@yutannihilation

NEWS on version 0.2.3 says:

For instance + is transformed to function(.x, .y) .x + .y. This
results in proper argument matching so that map(1:10, partial(-, .x = 5)) produces list(5 - 1, 5 - 2, ...).

If I understand correctly, using .y instead of .x, map(1:10, partial(-, .y = 5)), will produce list(1 - 5, 2 - 5, ...), right? But it won't:

map_int(1:10, partial(`-`, .y = 5L))
#>  [1]  4  3  2  1  0 -1 -2 -3 -4 -5

Any argument will produce the same result. What does it mean by "proper argument matching" here? Should I use as_mapper() explicitly by myself?

map_int(1:10, partial(`-`, any_inproper_argument = 5L))
#>  [1]  4  3  2  1  0 -1 -2 -3 -4 -5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions