@le.legioner has joined the channel
@shu—hung Thanks for the help yesterday. Everything seems to work now.
@philip.mcgrath good idea! I’m fussy and work hard to make sure I have “exact” require
s in each of my modules. That is, nothing require
’d if it’s not needed. It’s a way satisfy my intellectual need for knowing that I’m not pulling in more than I need. But there’s a price to pay for this fussiness. I end up spending a lot of time playing require
tetris and go fall into time sinks like the one that prompted my initial question (“how to I make my require
s cleaner”)
Platform is Win10. One issue is update-log-choices
takes time. It has to take the combination of a remote server and an Applications directory on that server, look in the logs/
directory of the current application choice, and build a list of all the .log
and .log.gz
files in logs/
or any subdirectory. Since we’ve been working remotely for 14+ months, this takes more time than when we were all in the same building. I thought (send log-choice clear)
would clear the choice%
instantly (visually that is). I’m going to play around with this a bit more, and see what I can figure out. The good news is that the log-choice
does eventually (within a second or two) show the correct new log choices instead of the old ones when you change the server or the application. I just wanted the choice%
to be empty while it was loading the new choices.
In the image below, when I pick a different application, I want the Log Choice to clear until I have read in the new log choices for the new chosen application.
I think you’re bumping into one of the hassles of an event loop, where refreshing the screen is part of the event loop, and it can’t run while the event-loop thread is occupied with (get-log-choices)
. To get quicker refresh, consider using (queue-callback (lambda () (for-each (λ (s) (send log-choice append s)) (get-log-choices))) #f)
, which will give the event loop a chance to refresh the screen before it starts on (get-log-choices)
.
I mean when this scribble snipped gets converted to html then the syntax-coloring of the html was not present. But requiring (for-label rash syntax/parse)
improves it: #lang scribble/manual
@(require
(for-syntax
racket/base
syntax/parse
)
(for-label
rash
syntax/parse
)
)
@(define-syntax (irash stx)
(syntax-parse stx
[(_ e1 e ...)
#`(codeblock #:keep-lang-line? #f
#,(datum->syntax #'e1 "#lang rash")
"\n" e1 e ...)]))
codeblock:
@codeblock{
#!/usr/bin/env bash
#lang rash
echo -e "hello \n codeblock" \| wc -l
}
Example from @hyperlink["<https://docs.racket-lang.org/rash/index.html?q=rash>"]{racket-rash}:
@codeblock{
#!/usr/bin/env racket
#lang rash
cd project-directory
echo The number of Racket files in this directory:
ls *.rkt \| wc -l
}
irash:
@irash{
#!/usr/bin/env bash
echo -e "hello \n irash" \| wc -l
}
It is however still far from perfect.
Thank you! I’ll try that!
@hesiyun1996 has joined the channel
I had the same behavior with queue-callback
, so I did the following instead, which gives enough feedback to the user; it will do for now. Later I can come back to find out why the clear
doesn’t happen right away. (define (update-log-choices)
(send log-choice set-label " (LOADING) ")
(send log-choice clear)
(send log-choice enable #f)
(let ([new-log-choices (get-log-choices)])
(for-each (λ (s) (send log-choice append s))
new-log-choices))
(send log-choice set-label "Log Choice:")
(send log-choice enable #t))
(I realize new-log-choices
doesn’t really do anything ahead of time, it’s left over from when I was trying different things.)
is there a way to build an array/matrix row-by-row? what I’m trying to do is (define bounds
(for/array: ([i (in-range 1 n)]) : (Vectorof Flonum)
(define col (array->list (array-slice-ref mat (list (::) `(,i)))))
(vector (apply min col)
(apply max col))))
but this ends up with an array of vectors, and not a 2 x n array
(Array Flonum)
also doesn’t work — again, array of arrays
or, at the very least, is there a for/array:
that accomplishes the same effect?
#lang racket
(require math/matrix)
(for*/matrix 4 3 ([i 4] [j 3])
(+ (* 10 i) j))
yeah, but how do I do exactly the thing where I’m doing (so the first column is the min and the second is the max) with for/matrix
since I’m getting two values out of col
at once
I haven’t grasped what your example does.
Is this close?
You have a matrix A of size (??) and now you want to construct a new matrix B with size nx2 (?), such that the ith row of B contains both the minimum and maximum of the ith column of A.
right
(array #[(apply min col)
(apply max col)])
does this work?
What about (if (= j 0) (apply min col) (apply max col))
that works
or it could
(define bounds
(for*/matrix: 2 m ([i (in-range 1 m)]
[fn : (-> Flonum * Flonum) (in-cycle (in-list (list min max)))]) : Flonum
(define col (array->list (array-slice-ref mat (list (::) `(,i)))))
(apply fn col)))
ah yes. type’s
(changed to m for other reasons)
Why not use matrix-col or matrix-cols to produce either a single or all columns. (that array-slice-ref looks confusing).
didn’t know it existed
There is also an matrix-map-cols, so you could write (matrix-map-cols min A) to get all the minima.
I wonder whether there is an elegant way of “merging” the cols of two matrices.
@semiotics has joined the channel
Shouldn’t it be quoted the other way around: Is there an “elegant” way of merging the cols of two matrices? ? Any merge operation is bound to be precisely defined, one way or the other. However, what is “elegant”? :slightly_smiling_face:
And it looks like the simplest way is to open the rash/scribblings/rash.scrbl
in the DrRacket and press the “Scribble HTML” button. Interestingly enough (from beginner’s perspective) this is also the fasted way how to get the html generated.
Ugh.
what data structure should I use if I want to routinely retrieve the first and last elements, and add to the beginning and end?
deque?
alright
do you need access to anything other than the first & last elements?
nope