Multiple distinct objects: Difference between revisions

no edit summary
(These tasks, Multiple distinct objects and Closures/Value capture, have some similarities)
No edit summary
Line 876:
: (val (cadr @@))
-> 2</lang>
 
=={{header|PowerShell}}==
Do some randomization that could easily return three equal values (but each value is a separate value in the array):
<lang PowerShell>
1..3 | ForEach-Object {((Get-Date -Hour ($_ + (1..4 | Get-Random))).AddDays($_ + (1..4 | Get-Random)))} |
Select-Object -Unique |
ForEach-Object {$_.ToString()}
</lang>
{{Out}}
<pre>
11/18/2016 3:32:16 AM
11/21/2016 3:32:16 AM
11/22/2016 7:32:16 AM
</pre>
Run the same commands a few times and the <code>Select-Object -Unique</code> command filters equal (but separate values):
<lang PowerShell>
1..3 | ForEach-Object {((Get-Date -Hour ($_ + (1..4 | Get-Random))).AddDays($_ + (1..4 | Get-Random)))} |
Select-Object -Unique |
ForEach-Object {$_.ToString()}
</lang>
{{Out}}
<pre>
11/18/2016 4:32:17 AM
11/21/2016 5:32:17 AM
</pre>
 
=={{header|PureBasic}}==
<lang PureBasic>n=Random(50)+25
308

edits