Mike,
Many thanks for the guidance. I’d already determined that my x: approaches to
#66 were going to involve waiting for the earth to crash into the sun—or,
equally unattractive, paying Google Cloud Platform for a fleet of “Godzilla”
class VMs—so I am looking in other directions. I took a br
Mainly for Ed Gottsman:
Chat really, but the thread is already here.
I've just solved Euler Problem 788 with the assistance of extended
precision numbers. The solution is
slow, taking over 14 minutes, but at least it's less than the lifetime
of the universe, unlike my (projected)
methods
If you don't mind some limitations, that:
(*) the ... token can only be used in explicit definitions
(*) the ... token must be preceded by a space
(*) the resulting definitions do not actually contain the ... delimited coments
(*) these definitions must use a lone ')' as the closing delimiter,
Ed,
no apology required :)
For the first approach:
If you want that, you can just start using it.
LEO came to my mind but you could as well
support it in another editor.
Write a function stripping your code off those
comments and feeding the remaining code to J.
Not much of a hassle except for l
Hauke,
My apologies: I expressed myself awkwardly. No disrespect was meant to any
editor. :-). Emacs and vim would be my choices, too, were I feeling a lot
more ambitious.
I have the sense that there are two basic approaches under discussion. In the
first (the one I think you’re articulati
Smarter than emacs? Vim. :)
editor wars aside, I’m having a hard time
imagining any editor smarter than these two
They may call themselves “smarter” but mostly
that translates to “more cumbersome”.
folds are natural in any coding editor,
and I guess Tim Pope would come up with a solution
showing
I expect that your ... could be made to work in explicit definitions,
but it would be a bit of work (getting error reporting right might be
a bit of a headache, and the interactive debugger would probably have
to be partially rebuilt to work with this concept). Plus, of course,
the actual implement
Jan-Pieter,
I like that file format a lot. Like JSON, it’s human- and machine-readable.
Further, a “slightly smart” editor (here I’m thinking perhaps of emacs macros)
could toggle between it (one token per line with comments) and a conventional
view (all tokens on one line, no comments). A m
I actually was intending for quite a while to propose an extension to
comments along the lines of the suggestions in this thread:
to use ... as line continuation indicator that turns everything after it up
to and including the next line break to be considered comment, and still
considers the line t
The LEO editor might be a good fit.
And yes, it’s really freaking (cool).
A script could generate the actual .ijs from snippets that are well
documented and those snippets may well be single J tokens.
Am 28.04.22 um 08:10 schrieb Ed Gottsman:
LOL. Fair question. Here’s another: if J adopted a
Raul,
D’oh. *Sigh*. It helps. Many thanks. I appreciate your patience as much as
your knowledge and willingness to help.
Ed
Sent from my iPad
> On Apr 27, 2022, at 3:36 PM, Raul Miller wrote:
>
> You should have used
> squares =: *: x: >: ? 1e5 $ 1e11
>
> Computing the square using f
LOL. Fair question. Here’s another: if J adopted a style standard around
ideograms (which are rendered vertically by default) for comments, would that
on the one hand slightly increase (as a percentage) its reputation for
obscurity among Western programmers but on the other dramatically increa
Probably more like
vert=: {{0!:0;:inv@;;.1 a:,<@}:@;:@,&' NB.';._2 m}}
{{)n
NB. y Possible squares of integers. Return either integer
NB. square roots or 0s.
intsqrt=: {{
y
* NB. Multiply to produce either integer square roots or 0s
y
= NB. 1s where the calculated square
I thought what was wanted was to write the _comments_ vertically, as in:
mean=: +/ % #
NB. i sr d l
NB. s ue i e
NB.md v n
NB. u i g
NB. c d t
NB. t e h
NB. i d
NB. o
NB. n b
NB. y
On Wed, 27 Apr 2022, Raul Miller wrote:
For what it's worth, J could easily
For what it's worth, J could easily be written vertically. But that's
probably not quite what people would want.
vertical=: {{ 0!:0;:inv{.@;:;._2 m}}
{{)n
mean
=:
+
/
%
#
}}vertical
mean 1 2 3
2
--
Raul
On Wed, Apr 27, 2022 at 2:01 PM Hauke Rehr wrote:
>
> Wha
What keeps you from writing your comments vertically‽
Am 27.04.22 um 14:50 schrieb Ed Gottsman:
If J were written vertically, it might be easier to comment.
--
--
mail written using NEO
neo-layout.org
--
Fo
You should have used
squares =: *: x: >: ? 1e5 $ 1e11
Computing the square using floating point and then converting to
extended precision means that many of your values in 'squares' are not
actually square.
For example:
x: *: 68824904566
4736867488519007764480
*: x: 68824904566
47368674
Oops. Foolish error as I prepared for presentation. My apologies.
Here’s the accurate implementation of intsqrt.
intsqrt =: 3 : 0
NB. y An array of possible integer squares
NB. Return 0 for non-squares or integer roots
s * y = x: *: s =. <. 0.5 + x: 10 ^ -: x: 10 ^. y
)
Note that it is explici
Project Euler #66, extended precision integer square roots, no spoilers
Continuing the discussion, for which again thank you all: I found that what I
really wanted was large *integer* square roots. Since this seems to come up
frequently in Project Euler problems and since I believe there are E
Hi Ed,
I was thinking of explaining Roger's sqrt code as part of next month's
NYCJUG.
You should take a look:
https://www.meetup.com/J-Dynamic-Functional-Programming/ .
Cheers,
Devon
On Fri, Apr 22, 2022 at 12:49 AM Ed Gottsman
wrote:
> Thanks to everyone who responded and in particular for the
Thanks to everyone who responded and in particular for the link to Roger Hui’s
essay. The wiki discussion was also very good.
(In an earlier life I disparaged “cargo cult” programming, in which you take a
few lines of source you don’t understand and integrate them into your program.
[That you
One way to obtain high precision roots is to use, say, Newton’s solution to
y = x^2 - a :
Given an estimate x(n-1), the next estimate is
xn = x(n-1) - y/(dy/dx), in Maths notation.
In J, (J701 on this iPad),
rt =: -:@] + (% +:) NB. x is number whose root is required, y an initial
guess
Showing the result in decimal:
23j13": sqrt 1x + *: 9x
9.05000
On Thu, Apr 21, 2022 at 3:18 PM Gilles Kirouac wrote:
> Ed If you expand the Extended Integers section (below by bob), you will
> see a link to an essay by Roger on 'Extended Precision Functions'. There
>
Ed If you expand the Extended Integers section (below by bob), you will
see a link to an essay by Roger on 'Extended Precision Functions'. There
is a Square Root verb.
NB. long rational result may exceed line length
sqrt 1x + *: 9x
1249987500062500625004687515
Gilles,
In Nuvoc the extended constant notation can be found here
https://code.jsoftware.com/wiki/Vocabulary/Constants#Extended_Integers
Having said that, it is hidden pretty well and most of its references are
previous documentation on the jsoftware site. There is certainly work to be
done on
Ed
You seem unaware of the extended precision constant notation:
"digits with a trailing x denote an extended precision integer"
https://www.jsoftware.com/help/dictionary/dcons.htm
[Where is the equivalent in NuVoc?]
I would rather write
1x + *: 9x
82
~ Gilles
Le
Square root does not produce an extended precision result.
<.@%: does produce an extended precision result, but that would not
resolve your problem here.
FYI,
--
Raul
On Thu, Apr 21, 2022 at 12:43 PM Ed Gottsman
wrote:
>
> Hello.
>
> I’m working on the Project Euler “Diophantine equation” pro
3!:0 %: x: 1 + x: *: x: 9
8
The square root cannot be represented exactly.
Henry Rich
On 4/21/2022 12:43 PM, Ed Gottsman wrote:
Hello.
I’m working on the Project Euler “Diophantine equation” problem (#66) and using J’s extended precision facilities. I’ve run into behavior that c
Hello.
I’m working on the Project Euler “Diophantine equation” problem (#66) and using
J’s extended precision facilities. I’ve run into behavior that confuses me.
Boiled down (and overusing x: just to be sure):
x: %: x: 1 + x: *: x: 9
9
That is (if my syntax is right),
29 matches
Mail list logo