This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Property { | |
[CmdletBinding()]param( | |
[Parameter(ValueFromPipeline)][psobject]$object, | |
[switch]$AsHash | |
) | |
Process { | |
If ($AsHash) { | |
$Property = [ordered]@{} | |
$Object.psobject.get_properties() | ForEach-Object { | |
$Property += @{ $_.Name = $_.Value } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-CurrentLineNumber { | |
$Invocation = Get-Variable MyInvocation -value -ea 0 2>$Null | |
If (!$Invocation) { $Invocation = $MyInvocation } | |
$Invocation.ScriptLineNumber | |
} | |
Function Get-CurrentFileLine { | |
if ($MyInvocation.PSCommandPath) { | |
"$(split-path -leaf $MyInvocation.PSCommandPath):$($MyInvocation.ScriptLineNumber)" | |
} else {"GLOBAL:$(LINE)"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Global:prompt { | |
If (!(Get-Variable MaxPrompt -ea 0 2>$Null)) { $MaxPrompt = 45 } | |
$loc = "$($executionContext.SessionState.Path.CurrentLocation)" | |
$Sig = " |>$('>' * $nestedPromptLevel)" | |
if ($Global:MaxPromptLength) { | |
$LocLen = $Loc.length; $SigLen = $Sig.Length | |
$Length = $LocLen + $SigLen | |
$Excess = $Length - $Global:MaxPromptLength | |
If ($Excess -gt 0) { | |
$Excess = [Math]::Min($Excess, $LocLen) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 subgoal | |
n, m, p : nat | |
H : leb n m = true | |
IHp : leb (p + n) (p + m) = true | |
______________________________________(1/1) | |
leb (S p + n) (S p + m) = true | |
(* How does assumption complete the goal? I agree it's true but don't see how Coq gets that. *) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) } | |
# Two parameters | |
map { param($x, $y) $x + $y } @(1,2,3) 10 | |
# Anonymous function as a value | |
$squareIt = { param($x) $x + $x } | |
map $squareIt @(1,2,3) | |
# One parameter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Text.RegularExpressions | |
exception QuitProgram | |
(* // defining this function causes the initial "> " to not be displayed first | |
let ProcessInput = | |
let input = System.Console.ReadLine() | |
try | |
let f = System.Single.Parse(input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpenXML-test-errors OXML-1 | |
open System.IO | |
open System.IO.Packaging | |
open DocumentFormat.OpenXml.Packaging | |
open DocumentFormat.OpenXml.Wordprocessing | |
[<EntryPoint>] | |
let Main args = | |
let byteArray = File.ReadAllBytes "Test.docx" | |
use mem = new MemoryStream() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dr. Syme meets Dr. Seuss :slightly_smiling_face: | |
// Expert FSharp 4.0 p. 165 read aloud: | |
module public GlobalClock = | |
type TickTock = Tick | Tock | |
let mutable private clock = Tick | |
let private tick = new Event<TickTock>() | |
let internal oneTick() = | |
(clock <- match clock with | |
Tick -> Tock | |
| Tock -> Tick) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open System.Collections.Generic | |
open System.Text | |
open System.Text.RegularExpressions | |
#load "Library1.fs" | |
open Library1 | |
// Define your library scripting code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; My solution | |
(defn intervs [s] | |
(let [sorted (sort (into #{} s)) | |
fs (first sorted)] | |
(cond (not (seq sorted)) () | |
(= 1 (count sorted)) (list [fs fs]) | |
(not= (inc fs) (second sorted)) (cons [fs fs] (intervs (rest sorted))) | |
:ELSE | |
(let [pairs (partition 2 1 sorted)] | |
(let [contig (take-while #(= (inc (first %)) (second %)) pairs) |
NewerOlder