amit@umn-cs.cs.umn.edu (Neta Amit) (07/16/88)
Do you know a trick (or an implementation) that will make 1 1 1 1 encode 2 return 0 0 1 1 ? Granted, the answer is ambiguous, as 0 1 0 1 etc. would qualify just as well, but nonethteless 0 0 1 1 is the "obvious" answer, derived from a unary representation. I's quite surprised to find out that all 4 of the implementations I have access to returned 0 0 0 0 . What gives? -- Neta Amit U of Minnesota CSci Arpanet: amit@umn-cs.cs.umn.edu
hans@umd5.umd.edu (Hans Breitenlohner) (07/16/88)
In article <6238@umn-cs.cs.umn.edu:: amit@umn-cs.UUCP (Neta Amit) writes:
::Do you know a trick (or an implementation) that will make
::
:: 1 1 1 1 encode 2
::
::return
::
:: 0 0 1 1 ?
::
::Granted, the answer is ambiguous, as 0 1 0 1 etc. would qualify just as
::well, but nonethteless 0 0 1 1 is the "obvious" answer, derived from a
::unary representation.
::
::I's quite surprised to find out that all 4 of the implementations I have
::access to returned 0 0 0 0 . What gives?
::
::
::
::
::--
:: Neta Amit
:: U of Minnesota CSci
:: Arpanet: amit@umn-cs.cs.umn.edu
all four implementations you checked are conforming to the ISO standard
for APL (actually I checked the fifth working draft standard, dated
June 30, 1983). The behavior you expect would be in conflict with
that standard.
jaxon@uicsrd.csrd.uiuc.edu (07/18/88)
As author of the "Represent" (aka "encode") definition as printed in the ISO standard, I should perhaps explain. Just as 10 is not a valid digit in base 10, so 1 is not a valid digit in base 1. I realize that "unary notation" (tallying) is often mistaken for a "positional" (fixed radix) number system, but the two concepts are centuries apart. Many APL statements produce a "unary" form of an integer argument, one close to what you'd expect from encode is: (reverse iota LIMIT) jot . leq N for origin 1, non-negative integers N. This is the traditional low-budget histogram program. (Actually ' *'[#IO + (above expr)] looks better). If you're wondering where the 2 goes in 1 1 1 1 encode 2, try 0 1 1 1 1 encode 2. Also try 0 1 encode 2.71828. regards - greg jaxon