Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let memoize f =
- let dict = new System.Collections.Generic.Dictionary<_,_>()
- fun n ->
- match dict.TryGetValue(n) with
- | (true, v) -> v
- | _ ->
- let temp = f(n)
- dict.Add(n, temp)
- temp
- let rec isConcat l = memoize(fun (s:string) ->
- match s with
- | "" -> true
- | x -> l |> List.exists (fun (w:string) -> x.Length >= w.Length && s.EndsWith w && (isConcat l (x.Substring(0,x.Length-w.Length)))
- ))
Advertisement
Add Comment
Please, Sign In to add comment