You could ask the opposite question -- if the fn's are available for Seq's, why even put them anywhere else when you could treat the DS as a seq? I'd assume that answer is notational convenience, and in some cases efficiency, when the "shape" of the DS dictates it, or for some other reasons.

As for Seq vs. List operations - a Seq can be infinite and is often computed lazily, while lists are finite and concrete - these reasons make it a poor choice to actualize into a concrete structure that can be operated on in reverse.

You could argue that lists shouldn't have an indexing operator because it's O(n) and not O(1) like arrays, but again, it's for convenience and it's up to the programmer to assume this is used on small lists, outside of loops, etc.

By on 11/15/2010 5:45 PM ()

Thank you.

I forgot about the Seq lazy infinite angle. That now makes perfect sense to me, which also explains why Seq.rev doesn't exist either.

When I was first learning F#, I did wonder why I had to place the collection type before the function.(like List.map and Seq.map). Certainly the function could be overloaded so the compiler could call the right one. Now I believe it was done that way to help the type inference engine and to make you think are you using the correct data structure for the problem at hand.

Thanks again.

By on 11/15/2010 6:24 PM ()
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