Created
December 6, 2011 11:24
-
-
Save mnzk/1437855 to your computer and use it in GitHub Desktop.
LazyList
This file contains 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
// see also. https://gist.github.com/1430157 | |
open Microsoft.FSharp.Collections | |
let distanceOfSameValueElements xs = | |
let rec loop i dict xs = | |
let x = LazyList.head xs | |
match Map.tryFind x dict with | |
| None -> loop (i + 1) (Map.add x i dict) (LazyList.tail xs) | |
| Some j -> i - j | |
loop 0 Map.empty (LazyList.ofSeq xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment