> … but there are still people working as “programmers” who obviously don’t
know this
> I’ve seen code segments featuring test clauses like
>       if (mybool == true)
> embarrassingly often

From *Some Exercises in APL Language Design
<https://www.jsoftware.com/papers/APLDesign.htm>*, §28:

*28. Array Logic*

   x← 5 ¯2.7 0 6

   (x>0)-(x<0)
1 ¯1 0 1

   x × (x>0)-(x<0)
5 2.7 0 6

The expression (x>0)-(x<0) is probably the first APL one-liner ever written
(*A Programming Language* <https://www.jsoftware.com/papers/APL.htm>, 1962,
§1.4). What make it work are that propositions have result 0 or 1 rather
than *true* or *false* and that functions work on entire arrays rather than
just on scalars.

Falkoff and Iverson explained the 0-1 definition in *The Design of APL*
<https://www.jsoftware.com/papers/APLDesign.htm> in characteristically
plain but telling language:

A very general and useful set of functions was introduced by adopting the
relation symbols < ≤ = ≥ > ≠ to represent functions (i.e., propositions)
rather than assertions. The result of any proposition was defined to be 0 or
 1 (rather than, say, *true* or *false*) so that it would lie in the domain
of other arithmetic functions. …

The adoption of the relation symbols as functions does not preclude their
use as *assertions* in informal sentences. For example, although one might
feel compelled to substitute “x≤y is true” for “x≤y” in the sentence “If
 x≤y then (x<y)∨(x=y)”, there is no more reason to do so than to substitute
“Bob is there is true” for “Bob is there” in the sentence which begins “If
Bob is there then …”.

Knuth wrote enthusiastically about this (the 0-1 thing, not the array
thing) in TNN <https://arxiv.org/PS_cache/math/pdf/9205/9205211v1.pdf> 1992,
calling it Iverson’s convention or Iverson brackets
<https://en.wikipedia.org/wiki/Iverson_bracket> and saying that it led to
“substantial improvements in exposition and technique”. If the worked
examples in TNN look familiar it’s because the simplification steps
resemble APL golfing.



On Thu, May 13, 2021 at 3:42 PM Hauke Rehr <[email protected]> wrote:

> that significant subdomain would be {0,1}
>
> in this domain,
>
> • both 0&= and =&0 are synonymous with -.
>   while 1&= and =&1 are synonymous with ]
>
> • 0&~: and ~:&0 are synonymous with ]
>   while 1&~: and ~:&1 are synonymous with -.
>
> • on a sidenote,
>   ⟨=~ x⟩ is =’s identity element here
>   ⟨~:~ x⟩ is ~:’s identity element here
>
> • so =/ (xs, x) is the same as =/ (xs, x, x, x)
>   and ~:/ (xs, x) is the same as ~:/ (xs, x, x, x)
>
> put another way, if VOID is an empty structure,
> we get the identity element by
>
> (=/ VOID) which is the same as (=/ ;~ VOID)
> and
> (~:/ VOID) which is the same as (~:/ ;~ VOID)
>
> [Elijah’s example was VOID =: '']
>
>
> … but there are still people working as “programmers”
> who obviously don’t know this
> I’ve seen code segments featuring test clauses like
> if (mybool == true)
> embarrassingly often
>
>
> Am 13.05.21 um 20:19 schrieb Roger Hui:
> > Not for any y.  For y in a significant subdomain of f.
> >
> >
> > On Thu, May 13, 2021 at 11:10 AM Elijah Stone <[email protected]>
> wrote:
> >
> >> The identity elements for = and ~: are 1 and 0 respectively, as
> >> illustrated by:
> >>
> >>     =/''
> >> 1
> >>     ~:/''
> >> 0
> >>
> >>
> >> I expect the identity element for some function f to be the value x such
> >> that, for any y, y -: y f x.  But this is clearly not the case here.
> >>
> >> Why not?
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >>
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
> --
> ----------------------
> mail written using NEO
> neo-layout.org
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to