[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Countchars



David:

I'll look for the NYT article.

>  Of course, in this context base 10 will do.

With a near-trivial mod, my routine will compute the length in any base. (See, below, the
substitution in two places of S/G 99, the variable base, for the hard-coded value of 10 in the
original.) Two interesting features here (at least, interesting to me). You can compute length for
a very long series, say n=123456789, using a very large base, say 1234567, without inventing 1234567
unique symbols (because, obviously, it doesn't matter what the symbols are, you're just counting
them). Also, again obvious, you can always make length equal to n (the last number in the series)
by increasing the base to (at least) n+1.

XPLeNCODE v2.0
b-gin [UNTITLED]
{{;5lensb#*}} Compute LENgth of Series 1 to n, variable base{032}
(S/G 50 in/out) [CLD][cr|lf]{002};*;   E.g., LENSB8 25 (input|output in base 10)[cr|lf];*;    Computes leng
th of first 25 numbers in octal (base 8)[cr|lf]{<}IF{<}VA{021
}50{>}<1{>}{<}SX01,@upr({<}VA$FR{>})+" n (n=integer>
0)"{>}{<}PR@01{>}{<}EX{>}{<}EI{>}{<}SX01,{<}PV50{>}{>}{<}SX02
,{<}VA$FR{>}{>}{<}SV03,b{>}{<}XS02,03,,03,99{>}{<}SX50,0{>}{<
}SX02,1{>}{<}SX03,1{>}{<}SX04,{<}PV99{>}{>}{<}LBa{>}{<}IF{<}P
V01{>}>{<}PV04{>}-1{>}{<}SX50,{<}PV50{>}+{<}PV02{>}*({<}PV04{
>}-{<}PV03{>}){>}{<}SX03,{<}PV04{>}{>}{<}SX04,{<}PV04{>}*{<}P
V99{>}{>}{<}SX02,{<}PV02{>}+1{>}{<}GLa{>}{<}EI{>}{<}SX50,{<}P
V50{>}+{<}PV02{>}*({<}PV01{>}-{<}PV03{>}+1){>}{<}PR@50{>}{002
}[cr|lf][cr|lf]
-nd
XPLeNCODE


--
Carl Distefano
cld@xxxxxxxx