Compared to modules, units are cumbersome to use. The only use case where you are forced to use units is where the dependency graph has a “diamond”. And with a little care it is a situation that often can be avoided.
Prior to the introduction of modules, units were in more wide-spread use. Now almost everyone uses modules. So not exactly legacy - but close.
Is there a standard way to shuffle a list? Picking a random permutation…
In python I’d say from random import shuffle
x = [[i] for i in range(10)]
shuffle(x)
@stefan.kruger Yes. Use shuffle
!
bah
Why can’t I find these things?
@stefan.kruger In case you don’t know about it, the search box in the Racket docs is very useful for that sort of thing: https://docs.racket-lang.org/search/index.html?q=shuffle
It also links to combinations
if you search for “powerset.”
Hey @mflatt, just a heads up that I’ve been getting segfaults from the Racket gui system on the latest version of mac os x.
The specific error being:
CGContextRef->C: argument is not non-null `CGContextRef' pointer
argument: #f
context...:
/Users/leif/racket/racket/collects/ffi/unsafe.rkt:1364:12
/Users/leif/rsrc/gui/gui-lib/mred/private/wx/cocoa/dc.rkt:117:9: send-arg203
/Users/leif/rsrc/gui/gui-lib/mred/private/wx/common/backing-dc.rkt:79:4: on-backing-flush method in backing-dc%
/Users/leif/rsrc/gui/gui-lib/mred/private/wx/cocoa/dc.rkt:113:0: do-backing-flush
/Users/leif/rsrc/gui/gui-lib/mred/private/wx/cocoa/canvas.rkt:357:5: paint-or-queue-paint method in .../wx/cocoa/canvas.rkt:271:3
/Users/leif/rsrc/gui/gui-lib/mred/private/wx/cocoa/canvas.rkt:69:2
about to suspend in atomic mode
[1] 33885 abort ./plt-games
(Also from DrRacket and any other gui program)
But the ‘goblet’ plt game seems to trigger the error the quickest.
Not sure if this is just a problem with my machine though.
Let me know your versions and I’ll try on my machine
@spdegabrielle honestly master.
But I suspect 7.3 would have the same issue.
I can check that now.
@leif Which version of macOS
Oh, the latest one, mojave I think?
Ya, it looks like mojave, 10.14.4
(Sorry, macOS isn’t really my primary OS at this point, so I’m a bit out of the loop if there’s something newer.)
When using a “vertical” slider, it is very squished. Not sure what I’m doing wrong.
(define frame (new frame%
[label "Example"]
[width 300]))
(define slider (new slider%
[label "Slider"]
[parent frame]
[min-value 0]
[max-value 100]
[init-value 50]
[style '(vertical)]))
(send frame show #t)
@spdegabrielle Hmm…it looks like when I use the 7.3 distribution, it stops segfaulting. Weird.
@leif Do you want me to build from master to reproduce? or is this a DrDr option?
@travis.hinkelman sorry for slow response. I can’t get a vertical slider at all - it just renders as a squashed horizontal.
#lang racket/gui
(define frame (new frame%
[label "Example"]
[width 600]
[height 600]))
(define hp (new vertical-pane% [parent frame]
[min-width 200]
[min-height 200]))
(define slider (new slider%
[label "Slider"]
[parent hp]
[min-value 0]
[max-value 100]
[init-value 50]
[min-width 200]
[min-height 200]
[vert-margin 10]
[horiz-margin 10]
[style '(horizontal)]))
(send frame show #t)
I want the slider value on the right (which is oddly created by using vertical for style).
I’m still confused by no vertical , but let me look at getting the label on the right
@spdegabrielle Eh. Honestly, its probably not worth it. I can’t find a single other person who can reproduce it, so I suspect there’s something odd with my macOS install.
Thanks for offering though. :slightly_smiling_face:
@leif your version number was lower than mine; I’m on 10.14.5 (18F132)
@leif I believe you wrote 10.14.4
@leif I saw that crash today, too. I was running one of the GL games and figured it was specific to that, but didn’t yet investigate. Racket crashed reliably, CS didn’t. Will investigate more as soon as I can.
@mflatt cool, thanks.w
and @spdegabrielle thanks for checking that.
@travis.hinkelman #lang racket/gui
(define fish%
(class object%
[init parent val]
(super-new)
(define hp (new horizontal-pane% [parent parent]))
(define slider
(new slider%
[label "Slider"]
[parent hp]
[min-value 0]
[max-value 100]
[init-value val]
[style '(horizontal plain)]))
(define label (new message%
[label (format "~a" val) ]
[parent hp]))
))
(define frame (new frame%
[label "Example"]
[width 300]
[height 300]))
(define charlie
(new fish% [parent frame] [val 55]))
(send frame show #t)
@travis.hinkelman This is a way to put the label on the right.
Thanks. It’s nice to know that there is a relatively straightforward workaround. I started toying around with that simple slider example when I saw this Reddit post: https://www.reddit.com/r/Racket/comments/cew4ws/ui_layout_question/
@luosha865 has joined the channel
I’ve pushed a change that should avoid the crash. I have no idea why it only started happening now or why it happens more for you.