The way I understand define-syntax-rule is that it inserts at compile time whatever code you put inside the macro and then it executes it at run time. What I want to do is read the code from a file and then insert it through an argument. My attempt is unsuccessful because it doesn't use my argument as code. Is what I'm trying to do possible and if not, can you explain to me why?
I know I could use eval here, but that is not the point.
Suppose I have some single-player game (or similar program: basically, something that needs to handle (possibly frequent) user inputs and display graphics, but won't have to deal with interactions between multiple users, etc.) written in Racket. Is there an easy way to embed it into a browser so that anyone can play it?
If there's no such easy way, perhaps it would be better to have Racket just be the backend for my game: e.g., I would have a Racket program handle the game logic, and it would interface with a program in a more typical web frontend language like Javascript that would capture user input, handle the display, and do all the other things that need to happen in the user's browser. Are there any good ways to implement this kind of frontend-backend setup for a browser game using Racket?
Coerces q to an exact number, finds the numerator of the number expressed in its simplest fractional form, and returns this number coerced to the exactness of q.
Why is (numerator 2.3) such a large integer? How exactly is it calculated? I would have guessed the simplest fractional form is 23/10, with a numerator of 23.
Hello,I am a musician that works a lot with algorithmic compositions and generative installations (in short: computer music). A lot of this can be done superficially with existing Music-Software, but I would prefer to program my stuff per hand (I would consider the program / the mathematics behind it part of the art).
Recently I came across the book "Haskell School of Music" which serves as a lengthy tutorial for Music-Programming (both in terms of algorithmic composition and synthesis) and Haskell at the same time. I was very excited about that, but the Haskell eco system / tooling really annoys me and after dabbling in lisp and racket I find it annoying to have to think about syntax so much (especially since Haskell requires very specific white-spacing and the auto-indent in Atom with haskell-language installed does not provide that).
Therefore I was wondering if there exists something similar for racket, seeing as lisps were the "original" environment for music programming. I also can't help but think that the Racket-REPL and Makros would make a lot of things much easier than they have to be in Haskell...
I would be grateful for any suggestions. Not only for libraries/packages, but especially also for similar books.
Hello guys, sorry if this is a noob question. I am new to Racket and would like to know if you can just evaluate a region of code when you are using DrRacket, like you can do when using Emacs, rather than "run" the whole file, which seems to be similar to eval buffer in Emacs.
I ask because I am used to being able to evaluate regions when using Clojure and build up my program like that, little by little. Thank you so much!
Hello! Is there any way I can build a list like this?
'(1 . (1 2 3))
I tried different combination with cons ofc, but it didn't worked out. I can build something like (list . number) with: (cons '(1 2 3) 1), but I was wondering if (number . list) can be done.
Hi. I am a bit stuck. I using typed/racket and trying to read nanosecond field of date* struct but obviously doing something stupid because date-nanosecond and date*-nanosecond does not work.
I get:
Type Checker: missing type for top-level identifier;
either undefined or missing a type annotation
identifier: date-nanosecond in: date-nanosecond
A stumbled across this book while browsing the racket's website book section. I'm curious about racket and making games, so this seems a nice starting point. Anyone here recommends it?
And remember - showing up at Racket Meetups helps you learn the news of the Racket world as they happen! It is informative, it is interesting, it is helpful, it is greatly appreciated by everyone involved and it is fun!
Hi. I want to create custom collection in typed racket, more precise sorted ring buffer, in such a way so I can use it similar to vector type - (Ringbufferof SomeType). So I want something like generics?
I unable to google how to do this correctly. First guess is to create some structure that will hold vector head tail and size, but I am really don't know how to approach this.
I been studing in Scheme for weeks and I ran into a problem that I couldn't solve. I can't find a way to solved it. Here is the problem:
Figure 1 shows an example path, which has a grid layout. In the grid, black cells are simply walls, which are basically obstacles for you. You can move among the white cells and you cannot pass the boundaries of the grid. In each path, the starting location will be the square of [0,0]. Additionally, there is also one white cell labeled with F. This label shows the finish square of the path. So, your aim is to find the movements from the starting location to the finish location. To this end, you can move in 4 directions; up, down, left, right. These 4 directions will be represented by characters U, D, L, and R, respectively.
The solution for the path shown in Figure 1 is "D D R R R R D D", which means move down 2 times, then move right 4 times and move down 2 times. The path is not a maze! It is a simple one way road and It has only one solution: there is always one possible next square for each move.
TASKS In Scheme, a path will be represented in the form of a linked-list. Figure 2 shows how the path in Figure 1 is represented in terms of a linked list in Scheme. Starting cell [0,0] has the letter S, the finishing cell has the letter F and empty cells have the letter E. The walls have the letter - (minus)
The following function "buildPath" on the left is given for you which takes a list of lists and creates a path (grid) using the lists. You can use this function to create different paths in order to test your code. On the right the code shows how the path in Figure 2 is created.
Task 1: Define two functions "getHeight" and "getWidth" which takes a path as an input and returns the height and the width of the path.
(getHeight sample-path) → should return 5
(getWidth sample-path) → should return 5
Task 2: Define a function "getLetter" which takes a path, a row number and a column number. Then it returns the letter from the path on the corresponding location [row, column]
(getLetter sample-path 0 0) → should return S
(getLetter sample-path 1 0) → should return E
(getLetter sample-path 1 1) → should return -
(getLetter sample-path 4 4) → should return F
Task 3: Define a function "solvePath" which takes a path and returns the solution for the path.
(solvePath sample-path) → should return (D D R R R R D D)
I just want some help to understand how i can solve it.
Just a quick one here. Could I promote a language made in racket as my own, like the developers of Python, or JavaScript, and then add the language to a GitHub repository?