< Back

Convert-PairMap

Sat Jan 18, 2020 11:29 am

NAME Convert-PairMap



SYNOPSIS

Perform functional-style operations on each pair of elements from two sequences or streams of objects in a

Powershell pipeline





SYNTAX

Convert-PairMap [-Expression] <ScriptBlock> [-InputObject] <Object[]> [-Right] <Object[]> [<CommonParameters>]





DESCRIPTION

Apply the given ScriptBlock expression to each member of the pair of pipelined Objects.





PARAMETERS

-Expression <ScriptBlock>

The anonymous (in-place) or named (as variable) single-argument lambda function to be applied to each

InputObject element. This must have a single-argument parameter block.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InputObject <Object[]>



Required? true

Position? 2

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Right <Object[]>

The right (second) sequence or stream of Objects from the Powershell pipeline.



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\># Multiple each element of a list by a factor from another list.



Convert-PairMap -InputObject @(1,2,3) -Right @(4,5,6) { param($l,$r) $l * $r }

4

10

18









-------------------------- EXAMPLE 2 --------------------------



PS C:\\># Multiple each element of a list by a factor from another list.



@(1,2,3) | Convert-PairMap -Right @(4,5,6) { param($l,$r) $l * $r }

4

10

18









-------------------------- EXAMPLE 3 --------------------------



PS C:\\># Zip two lists into a list of pairs.



@(1,2,3) | Convert-PairMap -Right @(4,5,6) { param($l,$r) @($1,$r) } -OutVariable pairs

$pairs.Count

3

$pairs[1]

2

5











RELATED LINKS