
Does anyone have a nice racket math expression ‘printer’ by any chance? pdf or pict or utf8, or ideally all of these? I want to render something like (+ -1 x (* -1/2 (expt (+ -1 x) 2)) (* 1/3 (expt x -3) (expt (+ -1 x) 3)))
( @soegaard2 )

racket-cas has an s-expression to tex formatter.

And I have an tex -> pdf -> pict library too. I’ll find the link.


I uses pdflatex
to turn the TeX into a pdf - and it also uses a few TeX packages. If you are using TeXLive, they ought to be installed.

Thanks!

I’ll need to convert my s-exp first, but that should be fine.

I think your example would work fine.


> (require racket-cas)
> (tex '(+ -1 x (* -1/2 (expt (+ -1 x) 2)) (* 1/3 (expt x -3) (expt (+ -1 x) 3))))
"$-1+x-\\frac{1}{2}{(-1+x)}^{2}+\\frac{{(-1+x)}^{3}}{3x^{3}}$"

nice!!

Renders as:

There is a ton of options to affect the output - but … erm … no documentation, so just ask.

Still a few simplifications are possible. But that’s a hard problem I think

Where did then (3) come from?

1/3 i guess

> (displayln (tex '(+ -1 x (* -1/2 (expt (+ -1 x) 2)) (* 1/3 (expt x -3) (expt (+ -1 x) 3)))))
$-1+x-\frac{1}{2}{(-1+x)}^{2}+\frac{{(-1+x)}^{3}}{{(3)\cdot x^{3}}}$

But the TeX was: \\frac{{(-1+x)}^{3}}{3x^{3}}$"
and the denominator is: {3x^{3}}

so there should be no parens?

I got a different output

though I haven’t updated racket-cas in a while, let me do that first

there’s a new-format
?

:crossed_fingers:

fixed!

Ah… I had forgotten that I rewrote the formatter in a different file.

Yeah, look in new-format.rkt to see the options.

1600+ lines!!

Well, it’s tricky.

several formats supported too, nice work!

Hmm. I think (require racket-cas)
still exports the old formatter, so maybe use (require racket-cas/new-format)
in order to get the new one.

For the sake of completeness: > (require racket-cas/new-format)
> (parameterize ([mode 'latex])(displayln (format '(+ -1 x (* -1/2 (expt (+ -1 x) 2)) (* 1/3 (expt x -3) (expt (+ -1 x) 3))))))
$-1+x+\frac{-1}{2}\cdot (-1+x)^2+\frac{1}{3}\cdot \frac{1}{x^3}\cdot (-1+x)^3$

Hmm. I am not too happy about that output.

the old tex formatter was doing a little better

Agree. Luckily it is way easier to fix bugs in the new formatter :slightly_smiling_face:

The initial version of the old formater was only intended to format normalized expressions - and the code looked fine. Then I extended it in a case-by-case manner to support unnormalized expressions too — and suddenly it became a mess.

ouch, I can imagine

I see that a <https://pkgd.racket-lang.org/pkgn/package/sudoku-solver|package of mine> has <https://pkg-build.racket-lang.org/server/built/test-fail/sudoku-solver.txt|failing tests> . The <https://git.sr.ht/~sschwarzer/sudoku-solver/tree/main/item/games/sudoku-solver.rkt|file that leads to the error output> is the main program and it (intentionally) complains if the command line doesn’t have arguments. There are no intentional tests in that file.
After seeing the failing tests output, I wrapped the (main)
invocation in a (module+ main ...)
and updated the package to the latest tag with the presumed fix, but the tests on the package server still fail. The “Last updated” field on the package server is about 20 minutes after I changed the package information to use the new tag.
I wonder what I should change to make the tests pass.

I think “Last updated” is updated means that the package server notices the change. However, to update the result, it will require an actual re-compilation, which is triggered more infrequently. I would wait for a day, and if the result is still not updated, report that the package server is dead.

Hm, the current test log output also seems to be after the package update. Do you mean the tests can happen a while after the re-compilation? I had assumed the whole test is actually build and tests together.
That said, if you don’t see a problem with my file, I’ll just wait a bit. :-)

I just pushed a new tag because I noticed the version in the info.rkt
lagged several versions after the Git tag. :confused: So if you look at my links and tags now, it’ll be even more confusing. :wink: Sorry for that.

What is “current test log output”? How do you know that it “seems to be after the package update.“?
FWIW, https://pkg-build.racket-lang.org/server/built/install/sudoku-solver.txt and https://pkg-build.racket-lang.org/server/built/test-fail/sudoku-solver.txt say that the latest re-compilation happened three days ago.

Ouch, I only looked at the time, not the date. :joy: I didn’t know the intervals could be that long.

The intervals are about 8 hours

Yes, it actually makes sense … making more assumptions :wink: , when I entered my package a few days ago, the package server noticed it and then ran the tests. After that, there were no changes to the package until today and my changes from today aren’t detected yet because the end of the current 8-hour interval hasn’t been reached.

@mflatt Are there conditions under which call-as-atomic
might handle an exception in such a way that it ignores the uncaught-exception-handler
(and therefore error-display-handler
) parameter?

The context is https://github.com/greghendershott/racket-mode/issues/543#issuecomment-859733422. I’ve been working on this for hours, trying everything I can think of, and even looking at mred
and call-as-atomic
code (with limited comprehension).

I definitely don’t want to suck you into this, too. But I wanted to ask in case you had some quick guess or insight. Otherwise no worries.

When I start up Racket (in DrRacket), and see this right at the beginning: > Language: racket, with debugging; memory limit: 128 MB. What is that “memory limit” supposed to be exactly? Obviously I’m using more than 128 MB of memory, so it must be a specific heap? I’m working on some larger sets of data and it’s constantly dying “out of memory” and asking me to double that limit until it’s okay. Can I easily pre-configure that number to be higher?

It’s a memory limit for your program.

Dr Racket runs your program under a custodian.

Custodians can have memory limits.

And terminate the program if the limit is exceeded.

Each tab gets a limited amount of memory. Change the limit in the Racket menu.

Also … it’s Honu day!

Ah, I see it now. Thanks.

for larger sets you might want to run from the command line?

I would have to look more when I’m at a keyboard. My default mode (right in many contexts, but maybe not this one) is to assume that an error in atomic mode is fatal with unreliable reporting.

Is there a standard way to bundle images(or other resources) with a Racket GUI application? Do I need to create a collection for my app?

You’ll want to use define-runtime-path
to reference the files, and then raco exe
and raco dist
to create the bundle.

I finally pushed code to datetime-lib
, datetime-doc
, and datetime-test
. I also updated the README of the first of these to give some hopefully useful information.

Does someone have a github action that does close to the same procedure as the build server?

I think @popa.bogdanp’s setup-racket is close

You just need to install the package and then test it with raco test

@samth, thanks!

Awesome. I wasn’t sure if there was any special extra —drdr stuff going on.

You can actually look at the command that runs in the test output

Exceptions during call-as-atomic
should be ok. I see that it’s documented that way, and I haven’t detected anything wrong in the implementation along those lines.

> You just need to install the package and then test it with raco test As I noticed, in https://git.sr.ht/~sschwarzer/sudoku-solver/tree/main/item/.build.yml I don’t even install the package to run the tests. But I think installing the package with raco pkg install
would be a sensible additional task to find installation problems.