
For anyone interested, http://www.timb.net/popular-languages.html is generated from the script at: https://github.com/tim-brown/rc-popular-programming-languages-plus
By all means, be interested in it (and contribute)… but I think it hits rosetta code quite hard; so please use it sparingly.

What does the black/white colors mean?

That most of the other languages implement it?

I think the colors signal category of the tasks

E.g., draft task vs real task

(I actually have been using this page in last few days :slightly_smiling_face:)

> please use it sparingly
A.k.a., use http://www.timb.net/popular-languages.html instead :slightly_smiling_face:

Got it!

@tim986 if you want to, you can update https://rosettacode.org/wiki/Rosetta_Code/Rank_languages_by_popularity#Racket to include a link to your GitHub.
You could also register a new account and ask the village pump (https://rosettacode.org/wiki/Rosetta_Code:Village_Pump) for a bot right (https://rosettacode.org/mw/index.php?title=Special%3AListUsers&group=bot). This will allow you to increase response limit, meaning you can decrease the number of request trips

The colours (if they’re working) indicate how many of the languages above racket in the scoreboard have the task implemented.
In a purely gamey kind of way, if you implement a 7
, then none of the other languages can catch up with racket by copying your implementation.

I can’t be querying the difference between real and draft tasks… drive that from the “tasks not implemented in racket” page.

Hmm. I was wrong then

@samth @mflatt thanks, thinking about it, I might also get away with running one racket and running multiple places within it.
It would probably be much better to just run separate processes and use shared memory, but the current setup of the program that I am embedding in would make that a bit hard :confused:

is there any way to get a PNG’s DPI with racket/draw?

(So far, the best I’ve got is just to use imagemagik with system
)

Basically (system "identify -format \"%x, %y\\n\" -units PixelsPerInch file.png")

But I suspect there’s a better way.

FWIW this is where it is in the standard: https://www.w3.org/TR/2003/REC-PNG-20031110/#11pHYs

This is the only png related package on pkgs: https://docs.racket-lang.org/png-image/index.html

I see. So that’s how photoshop and gimp store dpi.

I think the png->hash will give you the pHYs chunk.

Interesting, I’ll have to check it out.

I guess cairo doesn’t really deal with dpi per se.

I am still confused about the retina-thing. Why have more “drawing units” than pixels? https://docs.racket-lang.org/gui/windowing-overview.html#%28part._display-resolution%29

I think it is supposed to make things look … better?

is also confused

Likely because subpels are a thing.

That, and monitors do (imo) stupid interpolation.

And so they can use the data to make it clearer. (Although IMO, by clearer, they mean more blurry.)

@soegaard2 Actually there are more pixels than drawing units: “A Retina display provides two pixels per drawing unit”. This seems like a kluge to make images not too small on high-DPI displays.

Oh! I had it backwards.

….what on earth is a drawing unit?

Drawing units matches pixels on low resolution screens.

When high resolution screens were introduced Apple were afraid that old software would just draw using the same pixel width and height as always.

So they changed their apis from using pixels to drawing units.

Using the same width and height in drawing units will give the same size on both type of screens.

So is this an apple-specific thing then? Or do other operating systems do something similar for their screens now?

It seems to be a mixed bag: https://en.wikipedia.org/wiki/Resolution_independence

Great to see: " AmigaOS from version 2.04 (1991) was able to adapt its window controls to any font size."

Fascinating, thanks for the wiki link

A Rosetta task is to generate the first 20 “perfect totient” numbers. Can the “continue until 20 is found” be done more elegant with for
than this? #lang racket
(require math/number-theory)
(define (tot n)
(match n
[1 0]
[n (define t (totient n))
(+ t (tot t))]))
(define (perfect? n)
(= n (tot n)))
(define-values (ns i)
(for/fold ([ns '()] [i 0])
([n (in-naturals 1)]
#:break (= i 20)
#:when (perfect? n))
(values (cons n ns) (+ i 1))))
(reverse ns)

@soegaard2 I don’t know of a cleaner way to get that “take first 20 values of filtered sequence” behavior, unfortunately. Here’s the best I could do: #lang racket
(require math/number-theory)
(define (tot n)
(match n
[1 0]
[n (define t (totient n))
(+ t (tot t))]))
(define (perfect? n)
(= n (tot n)))
(for/fold ([ns '()] [i 0] #:result (reverse ns))
([n (in-naturals 1)]
#:break (= i 20)
#:when (perfect? n))
(values (cons n ns) (+ i 1)))

However, with the transducers library I’m working on, you could write this: (transduce (in-naturals 1)
(filtering perfect?)
(taking 20)
#:into into-list)

Without transducers and with just the reducer library I made*, you could write this: (for/reducer (reducer-limit into-list 20)
([n (in-naturals 1)]
#:when (perfect? n))
n)
…but I haven’t implemented reducer-limit
yet.**

The transduce solution looks optimal.

thanks for the data point :thumbsup:

with lazy streams and threading, you could do: (~> (for/stream ([n (in-naturals 1)]
#:when (perfect? n))
n)
(stream-take _ 20)
(stream->list))

or, I suppose: (stream->list
(stream-take
(stream-filter perfect? (in-naturals 1))
20))

Or this: (~> (in-naturals 1)
(stream-filter perfect? _)
(stream-take _ 20)
stream->list)
Beware that the stream code isn’t quite semantically equivalent, as it has different (and less desirable) GC behavior.