Skip to content

manojlds/pslinq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#pslinq

LINQ for Powershell.

##Available cmdlets

The following cmdlets are available as of now:

Aggregate-List

All-List

Any-List

Except-List

First-List

Intersect-List

Repeat-List

SelectMany-List

Single-List

Skip-List

SkipWhile-List

Take-List

TakeWhile-List

Union-List

Zip-List

Based on MoreLinq:

TakeEvery-List

###Aggregate-List

Examples:

Sum:

1..10 | Aggregate-List { $input + $acc} -seed 10
#65

Product:

1..10 | Aggregate-List { $acc * $input } -seed 1

String reverse:

"abcdefg" -split '' | Aggregate-List { $input + $acc }
#gfedcba

###All-List

Examples:

1..10 | All-List { $input -le 6 }
#False

###Any-List

Examples:

1..10 | Any-List { $input -eq 5 }
#True

###Except-List

Examples:

1..10 | Except-List 1,3,5,7
#2
#4
#6
#8
#9
#10

###First-List

Examples:

1..10 | First-List { $input -eq 5 }
#5
1..10 | First-List { $input -eq 11 }
#Throws exception

###Intersect-List

Example:

1..10 | Intersect-List $(5..15)
#5
#6
#7
#8
#9
#10

###Repeat-List

Example:

1..3 | Repeat-List 2
#1
#1
#2
#2
#3
#3

###SelectMany-List

Example:

"abc", "def" | SelectMany-List { $input.ToCharArray() }
#a
#b
#c
#d
#e
#f

###Single-List

Example:

1..10 | Single-List { $input -eq 5 }
#5
1..10 | Single-List { $input -ge 5 }
#Throws exception
1..10 | Single-List { $input -eq 11 }
#Throws exception

###Skip-List

Example:

1..10 | Skip-List 6
#7
#8
#9
#10

###SkipWhile-List

Example:

1..10 | SkipWhile-List { $input -le 8 }
#9
#10

###Take-List

Example:

1..10 | Take-List 3
#1
#2
#3

1..10 | Skip-List 3 | Take-List 3
#4
#5
#6

###TakeWhile-List

Example:

1..10 | TakeWhile-List { $input -lt 4 }
#1
#2
#3

###Union-List

Example:

"a", "b", "c" | Union-List "c", "d"
#a
#b
#c
#d

###Zip-List

Example:

"a", "b", "c" | Zip-List $(1..4) { $first + $second }
#a1
#b2
#c3

"a", "b", "c" | Zip-List $(1..3) { $first * $second }
#a
#bb
#ccc

##Based on MoreLinq:

###TakeEvery-List

1..10 | TakeEvery-List 2
#2
#4
#6
#8
#10

About

LINQ (LINQ2Objects) for Powershell

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published