From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 12B94BC6B for ; Wed, 2 Jan 2008 20:21:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAK5ye0fRVYT1i2dsb2JhbACQEQEBAQgCBiQFk0GEIg X-IronPort-AV: E=Sophos;i="4.24,235,1196636400"; d="scan'208";a="20851957" Received: from an-out-0708.google.com ([209.85.132.245]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 Jan 2008 20:21:04 +0100 Received: by an-out-0708.google.com with SMTP id b15so1500822ana.102 for ; Wed, 02 Jan 2008 11:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=pdG3cBFGUpucn8g47yjSad1QySXyDds8IYA7A+2AfGk=; b=hROQvtx3LFP9deQSNoXhEq1S+85RyoCg6MhCCI54WO9R2pqADZvqFCHNFpfq+rsV0WGBvX5PPKPlPZ8P3D3K/nyd8o8RQM+iLoMMK5A/49PUC7jBj8t0Cg0m8UKAzuns/Olkcew/zKAuQoMFn7aNAHpZVM0YMydkX/3cxumekGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=aa+O/SkXsM2YJgt75aU0NjwwLzM5H3HrgAtyqLhzM/oHiHK4fe9zrwQzz/Ks0jc0WR0oJj26mqygMeIDV5Ra20EmtuhfJJkofW/zlObhBDLlwfS+G0ePcMlsYghOQ8iyhfnTDwsNbzCM4KaR0Ec4lHtblj7M2LoOYWuV+66e1mY= Received: by 10.100.196.17 with SMTP id t17mr5476000anf.115.1199301663124; Wed, 02 Jan 2008 11:21:03 -0800 (PST) Received: from ?192.168.0.7? ( [69.152.95.238]) by mx.google.com with ESMTPS id 9sm21251422agc.25.2008.01.02.11.21.00 (version=SSLv3 cipher=RC4-MD5); Wed, 02 Jan 2008 11:21:01 -0800 (PST) Message-ID: <477BE419.8080400@gmail.com> Date: Wed, 02 Jan 2008 13:20:57 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Brian Hurt Cc: Kuba Ober , caml-list@yquem.inria.fr Subject: Re: [Caml-list] [NEWBIE] is there an in-place map? References: <200801021152.30105.ober.14@osu.edu> <477BC929.4030109@gmail.com> <477BCB94.8060208@janestcapital.com> In-Reply-To: <477BCB94.8060208@janestcapital.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; for-loop:01 recursion:01 recursion:01 recursive:01 arrays:01 edgar:98 wrote:01 clearer:01 ints:01 caml-list:01 arithmetic:01 tail:01 tail:01 data:02 argument:02 Brian Hurt wrote: > The OP did say "in place modification. > Kuba also said "the output array is given as the argument, not as a return value." > It depends. If you have to use multiple references to make the for-loop > work, then I've seen tail recursion be faster (and clearer). Any example of a faster tail recursion? > Also, if > you recalculate the ending requirement every recursive call, recursion > can be slower (in the above for loop above, for example, Array.length is > gaurenteed to be called only once). I have no problems precalculating the Array.length value, or recursing down to 0. > > Brian > A little testing results in some data: for arrays of 1024 ints and simple arithmetic operations, I get a 9% speed increase in using a for loop over recursion. E.