From: Jamison Hope <jrh@theptrgroup.com>
To: kawa@sourceware.org
Subject: Re: APL-style array indexing in Kawa - a sketch
Date: Tue, 18 Aug 2015 03:37:00 -0000 [thread overview]
Message-ID: <112A4F9C-EF11-4386-B0DC-BA93C01A9CA0@theptrgroup.com> (raw)
In-Reply-To: <55D2648B.2040203@bothner.com>
On Aug 17, 2015, at 6:47 PM, Per Bothner <per@bothner.com> 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?
> Why wouldn't you just use: (T [0 <: 3] 3) ?
Oh, right. I wasn't sure whether you could mix array indices and
scalar indices like that, but that certainly simplifies it.
> It seems reasonable to offer a 1-argument array-copy function.
> In addition to copying (necessary parts of) the data array,
> it would simplify the IntArray interface to an ArrayMapper.
>
> Note that array-copy is a special case of:
> (make-array-from-function SHAPE FUNCTION)
> since a rank-N array can be treated as N-ary function.
Yeah. It occurs to me that this general function->array concept
overlaps quite a bit with expression templates from C++. (This is a bit
off-topic w.r.t. APL style, but oh well.) In addition to doing this
index mapping to create arrays from other arrays by permuting elements,
it would be useful to have a mechanism to construct an array that keeps
the same indices but invokes a function on each element. So, perhaps
something like:
(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.)
--
Jamison Hope
The PTR Group
www.theptrgroup.com
next prev parent reply other threads:[~2015-08-18 3:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-14 1:59 Per Bothner
2015-08-17 20:24 ` Jamison Hope
2015-08-17 22:48 ` Per Bothner
2015-08-18 3:37 ` Jamison Hope [this message]
2015-08-18 4:12 ` Per Bothner
2015-08-18 4:43 ` Jamison Hope
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=112A4F9C-EF11-4386-B0DC-BA93C01A9CA0@theptrgroup.com \
--to=jrh@theptrgroup.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).