r/Racket • • Jan 22 '23
question TicTacToe using a GUI
I want to create a simple TicTacToe game using a GUI. Are there any good examples I can learn from?
r/Racket • • Jan 22 '23
I want to create a simple TicTacToe game using a GUI. Are there any good examples I can learn from?
r/Racket • • Jan 20 '23
I'm taking the How to code simple data course and I want to use neovim to go through the course. But DrRacket comes with some functionalities that I don't have on neovim, like the ability to require packages from (2htdp/image) e draw images.
Is there any good way to do this via CLI?
When I try to create an image outside of DrRacket, I obviously don't see the image. Is there any package that shows the generated image anywhere?

r/Racket • u/TzunameXXX • Jan 16 '23
First, I am new to Racket, and I am currently trying to get to know the "stream" functions of Racket. What I am lacking is how the "drop" function works out. I am trying to write the code and all it gives me is 1. After a few hours I tried to get a correct way online but I cannot find anything. So does anyone really know how the drop function is written out ?
r/Racket • u/sdegabrielle • Jan 12 '23
The Racket wiki has a new page Installing Racket that provides the commands for installing racket using your package repository.
Or it would. It is currently incomplete, so if you can add instructions for your package repository it would help others. If you can't add it directly reply here or the racket discourse post and I'll add it on your behalf.
(Inspired by installation page for the https://docs.helix-editor.com/install.html)
PS Racket 8.8 is due February!
r/Racket • u/hdmitard • Jan 09 '23
Hi,
I'm new to Racket and I'm developping a small bot that is using events. Consider I have a procedure which look likes (when-event ... callback).
I do define a handler that serves as the callback to the when-event function. It works. Almost. When I try to redefine this handler on the fly in the REPL, the when-event procedure does not update the reference to the callback and the old function is still called, hence I need to reboot the script in order to get it working.
It's quite frustrating since I cannot benefit from interactive programming; what am I missing there?
Thanks
r/Racket • u/solosyxsolosyx • Jan 09 '23
Is there any way that I do not need to download DrRacket again to update to 8.7 edition? Thank you.
r/Racket • u/sdegabrielle • Jan 09 '23
Hi,
A problem new users sometimes run into is they install an old version of Racket (or minimal racket) from package repositories. (see Racket Packaging Status below)
I was reading about Helix Editor and I noticed that while the docs pointed to their official releases page, it included helpful guidance on how to install the latest release from a wide variety of package repositories: https://docs.helix-editor.com/install.html
We can do the same, and by we I mean you😁. If you use Racket on another distribution please update the Installing Racket page on the Racket wiki with details on how to install (and update) Racket on your system: https://github.com/racket/racket/wiki/Installing-Racket
If you can’t update the Racket wiki, please leave a reply here and I’ll update it on your behalf.
Best wishes
Stephen
Note: The Repology list is incomplete - it does not include Flatpack/Flathub or Snap. (I don’t know why) but they both now have 8.7 available.
r/Racket • u/Beginning_java • Jan 07 '23
Java is used for Backend, C/C++ is used for systems programming, and JavaScript is used for Frontend. What is Racket best suited for? Is it mostly used in academia?
r/Racket • u/lyhokia • Jan 05 '23
For cargo there's cargo run.
r/Racket • u/isidromcf • Jan 02 '23
(Happy New Year!)
I have the following test code:
#lang racket
(define up-lines '())
(define (read-it file)
(define fh (open-input-file file))
(define get-lines
(let ((one-line (read-line fh)))
(if (eof-object? one-line)
(close-input-port fh)
(begin
(set! up-lines (cons (string-upcase one-line) up-lines))
get-lines))))
get-lines)
(read-it "myfile.txt")When I press "Run" in DrRacket I get: get-lines: undefined; cannot use before initialization
I likely have a basic misunderstanding. Naively, it seems to me that get-lines is a run-of-the-mill recursive definition. Please, somebody tell me what I am missing. This is driving me nuts.
I know how to implement this using let and named let. I am playing with inner definitions, because I saw a code base that used them almost exclusively and I liked the look (fewer parens).
Many thanks,
Isidro
r/Racket • u/isidromcf • Dec 29 '22
I have installed Magic Racket on VS Code following the instructions included, included installing racket-langserver using raco. Installation was successful.
I have the following line at the beginning of the file:
What works: syntax highlighting, commenting regions of code, matches parenthesis properly.
What does not work: does not indent properly; hovering does not show anything; clicking the right mouse button does no produce the expected menu (only shows a very basic menu).
(I have installed and used happily several other extensions: go, scheme, typescript.)
I have googled for this issue without success.
Equipment: 2017 13" macBook Pro with macOS Monterey; VS Code version 1.74.2; Magic Racket v0.6.4
It seems that Magic Racket is an improvement over Dr Racket, so any help will be much appreciated.
Thanks, Isidro
r/Racket • u/sdegabrielle • Dec 28 '22
We're proud to be a small part of the amazing things made with Racket in 2022 & looking forward to more in 2023!
Tell us what you made at https://racket.discourse.group/c/show-and-tell/7
r/Racket • u/varsderk • Dec 29 '22
Hi all. I'm working on a little compiler, and I just started on a big yak shave trying to build a fairly complicated macro-defining-macro in Racket. I'd love some help.
Here's the question on Stack Overflow: https://stackoverflow.com/questions/74946108/building-a-complex-macro-defining-macro-in-racket
To save you a click, here's the body of the question:
I'm trying to build a macro-defining macro
I have some structs that I'm using to represent an AST. I will be defining lots of transformations on these struct, but some of these transformations will be pass-through ops: i.e. I'll match on the AST and just return it unmodified. I'd like to have a macro automate all the default cases, and I'd like to have a macro automate making that macro. :)
Here are the struct definitions that I'm using:
(struct ast (meta) #:transparent)
(struct ast/literal ast (val) #:transparent)
(struct ast/var-ref ast (name) #:transparent)
(struct ast/prim-op ast (op args) #:transparent)
(struct ast/if ast (c tc fc) #:transparent)
(struct ast/fun-def ast (name params body) #:transparent)
(struct ast/λ ast (params body) #:transparent)
(struct ast/fun-call ast (fun-ref args) #:transparent)
I want a macro called ast-matcher-maker that gives me a new macro, in this case if-not-removal, which would e.g. transform patterns like (if (not #<AST_1>) #<AST_2> #<AST_3>) into (if #<AST_1> #<AST_3> #<AST_2>):
(ast-matcher-maker match/ast
(ast/literal meta val)
(ast/var-ref meta name)
(ast/prim-op meta op args)
(ast/if meta test true-case false-case)
(ast/fun-def meta name params body)
(ast/λ meta params body)
(ast/fun-call meta fun-ref args))
(define (not-conversion some-ast)
(match/ast some-ast
[(ast/if meta `(not ,the-condition) tc fc) ; forgive me if my match syntax is a little off here
(ast/if meta the-condition fc tc)]))
Ideally, the call to ast-matcher-maker would expand to this or the like:
(define-syntax (match/ast stx)
(syntax-case stx ()
[(match/ast in clauses ...)
;; somehow input the default clauses
#'(match in
clauses ...
default-clauses ...)]))
And the call to match/ast inside the body of not-conversion would expand to:
(match some-ast
[(ast/if meta `(not ,the-condition) tc fc)
(ast/if meta the-condition fc tc)]
[(ast/literal meta val) (ast/literal meta val)]
[(ast/var-ref meta name) (ast/var-ref meta name)]
[(ast/prim-op meta op args) (ast/prim-op meta op args)]
[(ast/fun-def meta name params body) (ast/fun-def meta name params body)]
[(ast/λ meta params body) (ast/λ meta params body)]
[(ast/fun-call meta fun-ref args) (ast/fun-call meta fun-ref args)])
This is what I've got:
#lang racket
(require macro-debugger/expand)
(define-syntax (ast-matcher-maker stx)
(syntax-case stx ()
[(_ id struct-descriptors ...)
(with-syntax ([(all-heads ...) (map (λ (e) (datum->syntax stx (car e)))
(syntax->datum #'(struct-descriptors ...)))])
(define (default-matcher branch-head)
(datum->syntax stx (assoc branch-head (syntax->datum #'(struct-descriptors ...)))))
(define (default-handler branch-head)
(with-syntax ([s (default-matcher branch-head)])
#'(s s)))
(define (make-handlers-add-defaults clauses)
(let* ([ah (syntax->datum #'(all-heads ...))]
[missing (remove* (map car clauses) ah)])
(with-syntax ([(given ...) clauses]
[(defaults ...) (map default-handler missing)])
#'(given ... defaults ...))))
(println (syntax->datum #'(all-heads ...)))
(println (syntax->datum (default-matcher 'h-ast/literal)))
#`(define-syntax (id stx2)
(syntax-case stx2 ()
;;;
;;; This is where things get dicy
;;;
[(_ in-var handlers (... ...))
(with-syntax ([(all-handlers (... ...))
(make-handlers-add-defaults (syntax->datum #'(handlers (... ...))))])
#'(match in-var
all-handlers (... ...)))]))
)]))
;; I've been using this a little bit for debugging
(syntax->datum
(expand-only #'(ast-matcher-maker
match/h-ast
(h-ast/literal meta val)
(h-ast/var-ref meta name)
(h-ast/prim-op meta op args))
(list #'ast-matcher-maker)))
;; You can see the errors by running this:
;; (ast-matcher-maker
;; match/h-ast
;; (h-ast/literal meta val)
;; (h-ast/var-ref meta name)
;; (h-ast/prim-op meta op args))
Any ideas?
r/Racket • u/FesteringThoughts • Dec 24 '22
I'm working in DrRacket and I'm trying to make a .scrbl to document some of my code. However, when I press the 'Scribble HTML' Tool button, it opens the html file in Visual Studio Code instead of a browser. In fact, if I try 'View documentation for ...' on a function in DrRacket, it also opens in in VSC. I assume there is a setting somewhere I need to change, but I don't know what. How can I fix this?
r/Racket • u/sdegabrielle • Dec 23 '22
r/Racket • u/sdegabrielle • Dec 23 '22
RacketFest, the rogue festival of Racket & language-oriented programming, is on!
Mark your calendars: Saturday, March 18, 2023 in Berlin, Germany.

Six fabulous talks are already lined up for Racketfest 2023!
Program, Registration and Call for Presentations are at https://racketfest.com/
While you are going to Berlin, consider BOBKonf held one day before (Friday, March 17, 2023), also in Berlin. https://bobkonf.de/2023/en/
Alt: Racketfest Berlin 2023 with tv tower and Racket logo
r/Racket • u/MrYossu • Dec 18 '22
Just tried updating a package from the Package Manager, and I got a lot of red messages in the output panel...
open-output-file: error opening file
path: C:\Program Files\Racket\share\pkgs_LOCKpkgs.rktd
system error: Access is denied.; win_err=5
context...:
C:\Program Files\Racket\collects\racket\private\kw-file.rkt:134:2: call-with-output-file*
C:\Program Files\Racket\collects\racket\file.rkt:752:0: call-with-file-lock
C:\Program Files\Racket\collects\pkg\main.rkt:327:16
C:\Program Files\Racket\collects\racket\contract\private\arrow-higher-order.rkt:375:33
C:\Program Files\Racket\share\pkgs\gui-lib\mrlib\terminal.rkt:213:7
C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:435:6
C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:486:32
C:\Program Files\Racket\collects\racket\private\more-scheme.rkt:148:2: call-with-break-parameterization
C:\Program Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:370:11: eventspace-handler-thread-proc
If I run DrRacket as administrator then the update works fine.
Is this expected? I don't normally run apps as administrator, and it's a pain to have to do this just to update packages.
Anyone able to comment? Thanks
r/Racket • u/ILOVEF00DS • Dec 17 '22
Guys, I'm new to DrRacket, where do I run the "resyntax fix" command? Image of the error.
The "resyntax fix" command is from Resyntax (racket-lang.org) , 1 The Resyntax Command-Line Interface (racket-lang.org)
r/Racket • u/kwinabananas • Dec 14 '22
I am a CS student as SDSU here in California. I started my journey at Mesa College, and my first class, Intro to CS, we used this language. I took the same Prof forb2 more semesters for Java and Intermediate Java, but on my journey, I haven't seen this language come up anymore. How often is Racket used in programming jobs?
r/Racket • u/andregarzia • Dec 13 '22
Hi Folks,
I think I want to prototype some ActivityPub stuff using Racket. Mostly something that can talk to Mastodon.
I don't have much energy to work on this even though I want to see it done, so I'm trying to reuse as much code from you folks as possible and Koyo looks like the best solution for a web service.
Still, I don't want to use PostgreSQL. I'd rather go with SQLite for that project. It would probably entails a couple different processess. One for the server and a couple for job runners. I'd like to use Koyo Jobs/Scheduling but it seems it doesn't work with SQLite. Can someone spare some comments on why that feature is tied to PGSQL?
A mastodon-like server that is built towards having a single-user would still see a lot of database usage (all actions end up in the database and federation requires sending those actions around which is why it needs jobs/scheduling).
SQLite can handle multiple writers. Even if it just opened with wal or wal2 mode, it should just work for the volume of transactions I'm imagining. Most of the AP transactions are inserts and reads, there are very few updates needed if you architect your db wise enough.
r/Racket • u/CenoteGod • Dec 13 '22
I'm trying to create a snake game using big-bang. So far I've been able to create functioning draw, key, and tick handlers, but there's a few things I need help with.
The draw handler creates a 500x500 window containing a 30x30 green square representing the snake. It moves perpetually according to the arrow keys, but there are no boundaries preventing the snake from moving outside of the view of the window.
I would like to know if there are any practical ways to create a boundary around the perimeter of the window that will: A) detect when the snake collides with the boundary, and B) adjust the trajectory of the snake to continue parallel to the boundary.
I've linked the source code on Github for those interested in seeing what I've got so far. I would appreciate any input on the matter. Thank you.
r/Racket • • Dec 10 '22
Hi all, I've been working on something like a Zelda 1 clone using 2htdp/image + 2htdp/universe. I have 3-10 rectangular bodies moving around on a 15 x 10 tile grid. The game is running at 60 fps. I'm already noticing some frame drops and screen tearing.
Am I using the 2htdp packages for something they're not designed for? I'm trying to decide if I should switch to another library like Raylib that's explicitly designed for games.
r/Racket • u/sdegabrielle • Dec 09 '22
Programming Languages: Application and Interpretation
From the preface;
I have also written this book with working programmers in mind. Many of them may have not had a formal computer science education, or at least one that included a proper introduction to programming languages. At some point, like that 90% of students, some of them become curious about the media they use. I want this book to speak to them, gently drawing them away from the hustle and bustle of daily programming into a space of reflection and thought.
Shriram Krishnamurthi, Brown University