tim986
2019-8-27 10:57:25

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.


soegaard2
2019-8-27 11:00:07

What does the black/white colors mean?


soegaard2
2019-8-27 11:00:44

That most of the other languages implement it?


sorawee
2019-8-27 11:01:00

I think the colors signal category of the tasks


sorawee
2019-8-27 11:01:10

E.g., draft task vs real task


sorawee
2019-8-27 11:01:38

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


sorawee
2019-8-27 11:02:40

> please use it sparingly

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


soegaard2
2019-8-27 11:02:44

Got it!


sorawee
2019-8-27 11:12:03

@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


tim986
2019-8-27 11:14:18

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.


tim986
2019-8-27 11:14:59

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


sorawee
2019-8-27 11:17:41

Hmm. I was wrong then


markus.pfeiffer
2019-8-27 16:18:28

@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:


leif
2019-8-27 17:42:14

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


leif
2019-8-27 17:42:42

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


leif
2019-8-27 17:43:29

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


leif
2019-8-27 17:43:40

But I suspect there’s a better way.


soegaard2
2019-8-27 17:44:51

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


soegaard2
2019-8-27 17:46:02

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


leif
2019-8-27 17:49:11

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


soegaard2
2019-8-27 17:49:12

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


leif
2019-8-27 17:50:07

Interesting, I’ll have to check it out.


leif
2019-8-27 17:51:09

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


soegaard2
2019-8-27 17:55:02

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


samdphillips
2019-8-27 17:55:52

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


samdphillips
2019-8-27 17:56:05

is also confused


leif
2019-8-27 18:06:52

Likely because subpels are a thing.


leif
2019-8-27 18:07:05

That, and monitors do (imo) stupid interpolation.


leif
2019-8-27 18:07:37

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


bill_temps
2019-8-27 20:11:17

@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.


soegaard2
2019-8-27 20:12:43

Oh! I had it backwards.


notjack
2019-8-27 20:20:49

….what on earth is a drawing unit?


soegaard2
2019-8-27 20:22:25

Drawing units matches pixels on low resolution screens.


soegaard2
2019-8-27 20:23:40

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


soegaard2
2019-8-27 20:24:21

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


soegaard2
2019-8-27 20:24:48

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


notjack
2019-8-27 20:41:00

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


soegaard2
2019-8-27 20:43:31

soegaard2
2019-8-27 20:44:00

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


notjack
2019-8-27 20:51:32

Fascinating, thanks for the wiki link


soegaard2
2019-8-27 22:22:13

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)


notjack
2019-8-27 23:24:18

@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)))


notjack
2019-8-27 23:25:14

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


notjack
2019-8-27 23:32:01

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.**


soegaard2
2019-8-27 23:37:27

The transduce solution looks optimal.


notjack
2019-8-27 23:38:09

thanks for the data point :thumbsup:


jaz
2019-8-27 23:40:28

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


jaz
2019-8-27 23:44:30

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


notjack
2019-8-28 02:09:31

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.