is there a way to require
a module from the REPL but with access to all its definitions (as in a module+
)?
@andreiformiga you might like enter!
@samth thanks, that’s exactly what I was looking for (thought about something like :m+ in GHCi actually)
As a beginner, I’d appreciate any feedback on the following short code snippet. It works, but I can’t shake the feeling that it is clumsy and perhaps really inefficient.
The goal is to generate pdfs-in-folder
, a set of paths to all PDFs and ePubs contained in the folder previously defined as path-to-pdfs
and its subdirectories.
(define pdfs-in-folder
(list->set
(for/list
([f (in-directory path-to-pdfs)]
#:when (member (path-get-extension f) '(#".pdf" #".epub")))
f)))
Thank you for any feedback on how to improve.
@ghoetker What you have seems good to me! Not inefficient. I probably wouldn’t bother doing list->set
unless the guarantee of uniqueness were super important to the code using this. Depending on my mood I might split this into two functions so it reads more clearly (to me). Like maybe: (define (pdf-extension? filename)
(member (path-get-extension filename)
'(#".pdf" #".epub")))
(define (pdfs-in-folder path)
(for/list ([f (in-directory path)]
#:when (pdf-extension? f))
f))
@greg Thank you so much. Splitting does improve readability. Set
is nice because I later to a set-subtract to identify which of these files are not present in a list of expected files.
@ghoetker Oh in that case, I forgot — there’s a for/set
you could use to produce that directly (no need to compose for/list
with list->set
).
I want a kind of “list” widget for lines of text. most of it can be done with a multiline text field but I need to highlight/select a line. I don’t see how to do that in racket/gui
@andreiformiga I have zero hands-on with racket/gui
, but: 1. What about using a list-box%
? That might be more understandable for users? 2. If you really want a multiline text-field%
, then the docs say "get-editor
returns the field’s editor, which provides a vast collection of methods for more sophisticated operations on the text", and one of those operations seems to be set-position
: https://docs.racket-lang.org/gui/text_.html#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._text~25%29._set-position%29%29
it’s a list box alright, looking in the widget gallery I thought it was some kind of a combo box
Hoping for help with something well beyond my experience. I have the following plist. The information I wish to extract is about a quarter of the way down, "<string>A/Amemiya–1984-Tobit–00.pdf</string>". Searching the Racket documents revealed xml/plist
. However, because I’ve not worked with parsing XML or plists before, I am stuck. If anyone could at least get me started, I would really appreciate it. Complete solutions also very welcome :smile:. Thank you very much.
<?xml version="1.0" encoding="UTF–8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList–1.0.dtd”> <plist version="1.0"> <dict> <key>$archiver</key> <string>NSKeyedArchiver</string> <key>$objects</key> <array> <string>$null</string> <dict> <key>$class</key> <dict> <key>CF$UID</key> <integer>7</integer> </dict> <key>NS.keys</key> <array> <dict> <key>CF$UID</key> <integer>2</integer> </dict> <dict> <key>CF$UID</key> <integer>3</integer> </dict> </array> <key>NS.objects</key> <array> <dict> <key>CF$UID</key> <integer>4</integer> </dict> <dict> <key>CF$UID</key> <integer>5</integer> </dict> </array> </dict> <string>relativePath</string> <string>aliasData</string> <string>A/Amemiya–1984-Tobit–00.pdf</string> <dict> <key>$class</key> <dict> <key>CF$UID</key> <integer>6</integer> </dict> <key>NS.data</key> <data> AAAAAAF8AAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAAA AAAAQkQAAf////8ZQW1lbWl5YS0xOTg0LVRvYml0LTAwLnBkZgAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//// /wAAAAAAAAAAAAAAAAABAAMAAAogY3UAAAAAAAAAAAAAAAAAAUEA AAIAOi86VXNlcnM6Z2hvZXRrZXI6QmliRGVza1BhcGVyczpBOkFt ZW1peWEtMTk4NC1Ub2JpdC0wMC5wZGYADgA0ABkAQQBtAGUAbQBp AHkAYQAtADEAOQA4ADQALQBUAG8AYgBpAHQALQAwADAALgBwAGQA ZgAPABoADABNAGEAYwBpAG4AdABvAHMAaAAgAEgARAASADhVc2Vy cy9naG9ldGtlci9CaWJEZXNrUGFwZXJzL0EvQW1lbWl5YS0xOTg0 LVRvYml0LTAwLnBkZgATAAEvAAAVAAIAD///AAA= </data> </dict> <dict> <key>$classes</key> <array> <string>NSMutableData</string> <string>NSData</string> <string>NSObject</string> </array> <key>$classname</key> <string>NSMutableData</string> </dict> <dict> <key>$classes</key> <array> <string>NSDictionary</string> <string>NSObject</string> </array> <key>$classname</key> <string>NSDictionary</string> </dict> </array> <key>$top</key> <dict> <key>root</key> <dict> <key>CF$UID</key> <integer>1</integer> </dict> </dict> <key>$version</key> <integer>100000</integer> </dict> </plist>