Skip to content

new GPO operator .map #15153

@p0W3RH311

Description

@p0W3RH311

in PS there are many operator collections: like -contains, -join, where, foreach.... every operator performs one specific task very well (except where and foreach GPO "General Purpose Operator"). it's great but
since ps does not yet implement linq it lacks other important operators like: .map()

$collection.map( {code} , arg1, arg2, $collection2 )

.map() traverses two lists in parallel, applying a scriptblock to the corresponding items from each list. If one list is longer, the extra elements are ignored.

arg1 = name of first variable in first collection
arg2 = name of second variable in second collection

proof of concept:


PS> (3,5,6).map( {  $a + $b } , a, b, (1,2,4) )
4
7
10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-DuplicateThe issue is a duplicate.WG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions