The problem here is that in F# (and most other functional languages), the list type is an immutable linked list. The reason List.rev is slow is because it has to traverse the entire list it's given, then create an entirely new data structure representing the reversed list.

I think the ideal solution would simply use arrays, unless there is a special reason you want to keep the sequence data in lists. Also, IMO, using arrays instead of lists doesn't make the code less "functional" -- you could still write a clean, recursive implementation of LCS based on them.

By on 1/3/2012 6:34 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper