[Jprogramming] Re: Replacement

Roger Hui rhui000 at shaw.ca
Fri Jul 6 06:33:16 HKT 2007


> First, I should note that (if you're going for conciseness) that
> expression contains a token which can be eliminated with a fairly
> obvious rephrasing.

rpl2 =: ] - (0 ,~ -/)@[ {~ ] i.~ {.@[
rpl2a=: ] - (-/ , 0:)@[ {~ {.@[ i. ]

Two tokens:

   # ;: 5!:5 <'rpl2'
19
   # ;: 5!:5 <'rpl2a'
17



----- Original Message -----
From: Raul Miller <rauldmiller at gmail.com>
Date: Thursday, July 5, 2007 12:14
Subject: Re: [Jprogramming] Re: Replacement
To: Programming forum <programming at jsoftware.com>

> On 7/5/07, david alis <david.alis at gmail.com> wrote:
> > Raul's method of reducing the replacement problem
> > into simple arithmetic is a classic.
> >
> > rpl2=: ] - (0 ,~ -/)@[ {~ ] i.~ {.@[
> >
> > It'd be nice to know when he first used it
> 
> First, I should note that (if you're going for conciseness) that
> expression contains a token which can be eliminated with a fairly
> obvious rephrasing.
> 
> Second, I used analogous mechanisms in APL back in the '90s
> (but my memory is not good enough for me to say much more than
> that).
> 
> Third, I have frequently wished for an operation analogous to
> addition (1-to-1, with an identity element and an inverse operation)
> which worked across the full domain of J's verbs.  But I 
> have never
> been able to comfortably decide what other properties it should
> have for literals and boxes.  But, even without an inverse 
> and support
> for nothing beyond the identity operation, this could be useful
> (for example, assembling data in a list using two different
> mechanisms, using "zeros" (fills, presumably) as placeholders
> for elements coming from the other mechanism -- this hypothetical
> operation could then combine the two results.

 


More information about the Programming mailing list