Skip to content

maktaba#function#Filter modifies input #250

Description

@flwyd

Documentation for maktaba#function#Filter says This is like |filter|, except {func} may be any maktaba callable and a new list is created. Unlike the builtin filter() function, {list} WILL NOT be modified in place.

The output from the following test indicates that it does modify the input.

let s:numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
echo 'starting list is' s:numbers
let s:odds = maktaba#function#Filter(s:numbers, {x -> x % 2 == 1})
echo 'list with odds is' s:odds
let s:threes = maktaba#function#Filter(s:odds, {x -> x % 3 == 0})
echo 'list with threes is' s:threes
echo 'now odds is' s:odds
echo 'now numbers is' s:numbers

Output:

starting list is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list with odds is [1, 3, 5, 7, 9]
list with threes is [3, 9]
now odds is [3, 9]
now numbers is [3, 9]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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