From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73102 invoked by alias); 18 Aug 2015 04:12:31 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 73083 invoked by uid 89); 18 Aug 2015 04:12:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 18 Aug 2015 04:12:29 +0000 Received: from [10.9.9.206] (helo=mailfront02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1ZRYG9-00044o-GC for kawa@sourceware.org; Tue, 18 Aug 2015 06:12:25 +0200 Received: from 70-36-239-58.dsl.dynamic.fusionbroadband.com ([70.36.239.58] helo=toshie.bothner.com) by mailfront02.runbox.com with esmtpsa (uid:757155 ) (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) id 1ZRYFf-0007BB-7G for kawa@sourceware.org; Tue, 18 Aug 2015 06:11:55 +0200 Subject: Re: APL-style array indexing in Kawa - a sketch To: kawa@sourceware.org References: <55CD4B6A.8010606@bothner.com> <4E24D268-9062-465B-BF2B-966806394A39@theptrgroup.com> <55D2648B.2040203@bothner.com> <112A4F9C-EF11-4386-B0DC-BA93C01A9CA0@theptrgroup.com> From: Per Bothner Message-ID: <55D2B087.2020506@bothner.com> Date: Tue, 18 Aug 2015 04:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <112A4F9C-EF11-4386-B0DC-BA93C01A9CA0@theptrgroup.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-q3/txt/msg00029.txt.bz2 On 08/17/2015 08:37 PM, Jamison Hope wrote: > On Aug 17, 2015, at 6:47 PM, Per Bothner wrote: > >> We could define [<:] as a supported syntax (see $bracket-list$ in syntax.scm). >> It would be relative easy to define 0 as the default lower bound, but that >> doesn't quite do what you want. We could define [<;] as a special magic value >> that gets coerced to a specific range depending on context. > > Hmm can we pick something that won't confuse paredit mode? I'm not familiar with paredit - but why would [<:] confuse it? > (array-map (lambda (x) (* 2 x)) ARR) => a new array where each element > is doubled in value. > > (array-map + ARR1 ARR2) => a new array representing the elementwise sum > of the elements of ARR1 and ARR2. > > (I'm imagining that the array-map call wouldn't allocate a new data > buffer, but would just close over the supplied function and array(s), > lazily applying the function to array elements as needed.) "Lazily" is confusing here. I think array-map should eager, in the same way vector-map is. What it should do: (1) Figure out the shape of the result. (The same as the argument, if a single argument; otherwise they may be "broadcast" in the Racket sense.) (2) Allocate an Object[] buffer for the result whose length is the element-count of the shape. (3) Iterate of the shape (which is the same as iterating over the buffer); extract the corresponding argument array value using the same (or broadcast) indexes; call the function. http://docs.racket-lang.org/math/array_pointwise.html The Racket array functions is another place to look for inspiration. -- --Per Bothner per@bothner.com http://per.bothner.com/