The reason is memory management of the intermediate list. It can be up to twice as slow as List.map. We are measuring every other implementation relative to it. This approach is graphed as “naive tail-rec” above. The usual approach to making List.map safe is to make it tail-recursive by constructing an intermediate list of results, then reversing it. This usually terminates your program with exception Stack_overflow.įor this second reason, List.map is often considered “unsafe,” and users often look for a replacement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |