Re: Introduction to Functional Programming in OCaml at Paris Diderot (MOOC)
"Hendrik Boom [email protected] [ocaml_beginners]" <[email protected]> Wed, 17 Aug 2016 23:42:26 -0400
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 17, 2016 at 08:47:41PM -0500, Douglas Lewit [email protected] [ocaml_beginners] wrote: > Hendrik, > > Thanks for the reply. Yes, I like that Ocaml is functional but not > exclusively functional. It's a nice language. I just wish there were more > books out there to support the language. There are hundreds of books on C, > C++, Java, Python, Ruby, etc but very little good documentation to support > Ocaml. ( There's some books out there. I like the stuff by Whitington. *Real > World Ocaml* is okay, but some of it is just way over my head at this point > in my development as a programmer. ) > > Regarding arrays, here's a question. What do you mean by "random access"? > If an array has 100 elements in it and I want to access the element at > index #83, how is that random access? What's random about it? As for > inserting elements into the middle of an array, yes, I can see how that > would be very problematic. I remember trying that in Java once. It was a > fun exercise to do, but does require some careful planning if you want the > program to work properly. > Well, #83 is sort of a random number in the middle. If the data structure were a list, you'd have to count all the way through the list to get to the one you want. Whereas wth an array, it's a brief indexing calculation to get the machine address of the element, and there you are. If you were, say, picking random elements in the array, this would be efficient, which is why an array is usually considered a random access data structure. For a list, not so. As far as I can remember, the term random access was first used to describe disk drives, which could seek rapidly to any spot on the disk; in contrast to tape drives, which were called sequential access. > Thanks for the feedback. Have a great week! You are quite welcome. -- hendrik