Function global:gen-num_array_hash
{
[array[]]$num_array=1..1000
$global:num_array_hash=$num_array | % {
[array[]]$rand_out=$(get-random); foreach ($i in $rand_out)` {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:gen-alpha_array_hash
{
[array[]]$alpha_array="A","B","C","D","E"
$global:alpha_array_hash=$alpha_array | % {
[array[]]$rand_out=$(get-random); foreach ($i in $rand_out)` {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Results look like this:
The demonstration run is:
PS C:>[array[]]$names="Peter","Paul","Mary"
PS C:\> foreach ($i in $names) {[array]@{$i.getvalue(0)=1}}
Name Value
---- -----
Peter 1
Paul 1
Mary 1
PS C:\> foreach ($i in $names) {[hashtable]@{$i.getvalue(0)=1}}
Name Value
---- -----
Peter 1
Paul 1
Mary 1
PS C:\Windows\system32> [array]@{Peter=0;Paul=1;Mary=2}
Name Value
---- -----
Paul 1
Peter 0
Mary 2
PS C:\Windows\system32> [hashtable]@{Peter=0;Paul=1;Mary=2}
Name Value
---- -----
Paul 1
Peter 0
Mary 2
PS C:\Windows\system32> [array[]]@{Peter=0;Paul=1;Mary=2}
IsReadOnly : False
IsFixedSize : False
IsSynchronized : False
Keys : {Paul, Peter, Mary}
Values : {1, 0, 2}
SyncRoot : System.Object
Count : 3
PS C:\Windows\system32> [hashtable[]]@{Peter=0;Paul=1;Mary=2}
Name Value
---- -----
Paul 1
Peter 0
Mary 2
PS C:\Windows\system32>[array[]]$names="Peter","Paul","Mary"
PS C:\Windows\system32> foreach ($i in $names) {[array]@{$i=1}}
Name Value
---- -----
{Peter} 1
{Paul} 1
{Mary} 1
PS C:\> foreach ($i in $names) {[array]@{$i.getvalue(0)=1}}
Name Value
---- -----
Peter 1
Paul 1
Mary 1
PS C:\> foreach ($i in $names) {[hashtable]@{$i.getvalue(0)=1}}
Name Value
---- -----
Peter 1
Paul 1
Mary 1
PS C:\> foreach ($i in $names) {[hashtable]@{$i.getvalue(0)=@(0..2)}}
Name Value
---- -----
Peter {0, 1, 2}
Paul {0, 1, 2}
Mary {0, 1, 2}
PS C:\> foreach ($i in $names) {[array]@{$i.getvalue(0)=@(0..2)}}
Name Value
---- -----
Peter {0, 1, 2}
Paul {0, 1, 2}
Mary {0, 1, 2}
[array[]]$array=0..2
PS C:\> foreach ($i in $names) {[array]@{$i.getvalue(0)=$array.SyncRoot}}
Name Value
---- -----
Peter {0, 1, 2}
Paul {0, 1, 2}
Mary {0, 1, 2}
PS C:\Windows\system32> foreach ($i in $names) {[array[]]@{$i=1}}
IsReadOnly : False
IsFixedSize : False
IsSynchronized : False
Keys : {Peter}
Values : {1}
SyncRoot : System.Object
Count : 1
IsReadOnly : False
IsFixedSize : False
IsSynchronized : False
Keys : {Paul}
Values : {1}
SyncRoot : System.Object
Count : 1
IsReadOnly : False
IsFixedSize : False
IsSynchronized : False
Keys : {Mary}
Values : {1}
SyncRoot : System.Object
Count : 1
PS C:\Windows\system32> foreach ($i in $names) {[hashtable[]]@{$i=1}}
Name Value
---- -----
{Peter} 1
{Paul} 1
{Mary} 1
PS C:\Windows\system32> 0..2 | % {foreach ($i in $names) {[array]@{$i=$input}}}
Name Value
---- -----
{Peter} {0}
{Paul} {0}
{Mary} {0}
{Peter} {1}
{Paul} {1}
{Mary} {1}
{Peter} {2}
{Paul} {2}
{Mary} {2}
PS C:\Windows\system32> foreach ($i in $names) {0..2 | % {[array]@{$i=$input}}}
Name Value
---- -----
{Peter} {0}
{Peter} {1}
{Peter} {2}
{Paul} {0}
{Paul} {1}
{Paul} {2}
{Mary} {0}
{Mary} {1}
{Mary} {2}
Function global:XHASH
{
function Check-Random {workflow wrand {get-random -set (get-random);get-random -set (get-random);get-random -set (get-random)} wrand}
[array[]]$wrand_out=Check-Random
[array[]]$X="X"
$Xhash=$X | % { foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}}
$Xhash
}
$a=0..100 | % {XHASH}
$a.Values
[array[]]$b=$a.Values | sort
$b.count
($b| Select -unique).count
Function global:XYZHASH
{
function Check-Random {workflow wrand {get-random -set (get-random)} wrand}
[array[]]$wrand_out=Check-Random
[array[]]$XYZ="X","Y","Z"
$global:XYZhash=$XYZ | % { foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}}
}
$XYZhash
$a=0..100 | % {XYZHASH}
$a.Values
[array[]]$b=$a.Values | sort
$b.count
($b| Select -unique).count
Function global:XYZHASH
{
function Check-Random {workflow wrand {get-random -set (get-random);get-random -set (get-random);get-random -set (get-random)} wrand}
[array[]]$wrand_out=Check-Random
[array[]]$XYZ="X","Y","Z"
$global:XYZhash=$XYZ | % { foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}};break}
}
Function global:XYZHASH
{
function Check-Random {workflow wrand {get-random -set (get-random)} wrand}
# [array[]]$wrand_out=Check-Random
[array[]]$XYZ="X","Y","Z"
$global:XYZhash=$XYZ | % { [array[]]$wrand_out=Check-Random; foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:XYZHASH
{
function Check-Random {workflow wrand {get-random -set (get-random)} wrand}
[array[]]$XYZ=1..100
$global:XYZhash=$XYZ | % { [array[]]$wrand_out=Check-Random; foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:XYZHASH
{
function Check-Random {workflow wrand {get-random -set (get-random)} wrand}
[array[]]$XYZ=1..10000
$global:XYZhash=$XYZ | % { [array[]]$wrand_out=Check-Random; foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:XYZHASH
{
function Check-Random {get-random}
[array[]]$XYZ=1..10000
$global:XYZhash=$XYZ | % { [array[]]$wrand_out=Check-Random; foreach ($i in $wrand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:gen-num_array_hash
{
[array[]]$num_array=1..1000
$global:num_array_hash=$num_array | % { [array[]]$rand_out=$(get-random); foreach ($i in $rand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
Function global:gen-alpha_array_hash
{
[array[]]$alpha_array="A","B","C","D","E"
$global:alpha_array_hash=$alpha_array | % { [array[]]$rand_out=$(get-random); foreach ($i in $rand_out) {[array]@{$_.getvalue(0)=$i.item(0)}}};break
}
No comments:
Post a Comment