huu2uan
2019-8-18 12:09:46

@huu2uan has joined the channel


soegaard2
2019-8-18 13:47:52

Spot the error (to run it, save it as “most-common.rkt”) #lang racket ;;; Problem ;;; Given a text file and an integer k, print the k most ;;; common words in the file (and the number of occurences) ;;; in decreasing frequency. (define (solution file k) (define freqs (make-hash)) (define (add word) (hash-update! freqs word add1 1)) ; read and compute frequencies (with-input-from-file file (thunk (for ([line (in-port read-word)]) (displayln line) (add freqs)))) freqs) (define (read-word in) (define (peek) (peek-char in)) (define (skip) (read-char in)) (define (read) (read-char in)) (let loop () (define c (peek)) (cond [(eof-object? c) (read)] [(not (char-alphabetic? c)) (skip) (loop)] [else (list->string (for/list ([_ (in-naturals)] #:break (not (char-alphabetic? (peek)))) (read)))]))) (solution "most-common.rkt" 3)


soegaard2
2019-8-18 13:48:10

The number k isn’t used yet.


soegaard2
2019-8-18 13:50:08

sorawee
2019-8-18 15:22:51

@soegaard2 in-port here is super slow. I don’t know why


soegaard2
2019-8-18 15:23:14

In my case - I made a silly mistake.


soegaard2
2019-8-18 15:23:29

(add freqs) should have been (add line)


soegaard2
2019-8-18 15:23:37

It took a while before a noticed.


sorawee
2019-8-18 15:25:24

Ah, and it’s this that takes a lot of time


sorawee
2019-8-18 15:25:26

Make sense


soegaard2
2019-8-18 15:26:19

The amount of slow down is surprising though.


soegaard2
2019-8-18 15:27:21

I don’t get why hash-update! becomes the bottleneck.


soegaard2
2019-8-18 15:28:26

It needs to compute a hash of a hash table, but the the tables isn’t that large.


soegaard2
2019-8-18 16:20:07

Is there an existing function that works like uniq?


soegaard2
2019-8-18 16:20:09

notjack
2019-8-18 17:31:56

@soegaard2 remove-duplicates, I think


soegaard2
2019-8-18 17:34:58

I knew it!


michaelmmacleod
2019-8-19 02:18:03

Anyone know what I’ve got to do to get the racket package server to build documentation for my package, qualified-in? It’s been on the package server for a couple days. Locally, raco pkg install builds the documentation correctly (I can view it with raco docs qualified-in). https://pkgs.racket-lang.org/package/qualified-in


sorawee
2019-8-19 02:35:38

Seems like package server is dead


sorawee
2019-8-19 02:35:52

The last successful build is on August 14


gfb
2019-8-19 02:36:52

The index of packages is rebuilt every few minutes, for example to point to a new version of the package (often that “pointing” is just registering the new checksum). But the packages themselves are built on the server to report whether they build, have dependency problems, etc, as well as link the documentation, only every few days.


sorawee
2019-8-19 02:38:11

CC: @jeapostrophe


notjack
2019-8-19 06:41:26

@michaelmmacleod qualified-in is a great idea btw, excellent job