caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* optimization of sequence of List.map and inlining
@ 2008-06-10 19:01 Charles Hymans
  2008-06-10 19:21 ` [Caml-list] " Jon Harrop
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Charles Hymans @ 2008-06-10 19:01 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

Let's say, I have the following code:

  let f l = List.map succ l

  ....

  let l = f l in
  let l = List.map succ l in
    do_something_with l


Is there a way to tell the compiler to optimize it so that it runs as fast
as this code:
  let l = List.map (fun x -> succ (succ x)) l in
    l
In the first case, there are two passes where succ is applied to each
elements of the list.
In the second case, there is only one pass that applies succ twice to each
element of the list.

Thank you,

[-- Attachment #2: Type: text/html, Size: 778 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-17 14:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-10 19:01 optimization of sequence of List.map and inlining Charles Hymans
2008-06-10 19:21 ` [Caml-list] " Jon Harrop
2008-06-10 20:55   ` Richard Jones
2008-06-10 22:10 ` Peng Zang
2008-06-10 23:07 ` Brian Hurt
2008-06-17 14:36 ` Jon Harrop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).