Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] partial eval question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-27 (01:42)
From: Ben Kavanagh <kavabean@l...>
Subject: [Caml-list] partial eval question

Say I have a function such as pow defined as

let pow n x = 
    let rec pow_iter (n1, x1, p1) = 
        if (n1 = 0) then p1 
        else if (n1 mod 2 = 0) 
		 then pow_iter(n1/2, x1*x1, p1) 
             else pow_iter(n1-1, x1, p1*x1)
    in pow_iter(n, x, 1);;

and I say 

let pow2 = pow 2

Are there any ML implementations that would automatically perform
partial evaluation to create pow2 instead of using closures, possibly
unfolding the pow_iter call? Would Caml ever have this capability?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: