Created
September 25, 2015 20:10
-
-
Save wallymathieu/dda0eca33a18f5d07290 to your computer and use it in GitHub Desktop.
stitch
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
| let r = [0;1;2;3] | |
| let stitch s= | |
| let head = s |> Seq.head | |
| let tail = s |> Seq.skip 1 | |
| tail |> Seq.scan (fun state elem-> (snd state, elem)) (head, head) | |
| |> Seq.skip 1 | |
| |> Seq.toList | |
| open System.Linq | |
| let stitch_and_end (s: 'a seq) (last: 'a) = | |
| let stitched = stitch s | |
| let e = Enumerable.Last s | |
| stitched @ [(e, last)] | |
| stitch r | |
| stitch_and_end r -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment