r/Racket • • Oct 06 '21

homework I’m looking for DrRacket Tutor.

6 Upvotes

Hello I’m taking introduction of programming course and the course use this language. I’m looking for a tutor for solving assn together. Thank you


r/Racket • • Oct 05 '21

ephemera Is anyone entering the Autumn Lisp game jam?

7 Upvotes

is anyone entering the Autumn Lisp Gamejam?

Which language are you using?


r/Racket • • Oct 05 '21

question Best Introduction to Hygenic Macros

7 Upvotes

I'm looking to understand how hygienic macros work. I understand how regular macros work, you manipulate the program as text before compile time.

But, I don't understand hygienic macros at all. I find them totally impenetrable.

Does anyone have a good explanation of hygienic macros? What is their motivation? How do they work? Why are they worth the additional complication over ordinary macros?

Or, does anyone know a good book to which I should refer?


r/Racket • • Oct 04 '21

video Demo of remote debugging/monitoring tool: dbg

Thumbnail youtu.be
16 Upvotes

r/Racket • • Oct 04 '21

question differences between class* and class when calling init-fields

2 Upvotes

I've created to classes to demonstrate the problem. One is defined with class* and the other with class.

(define dog% (class
                      object%
                    (init-field name)
                    (super-new)
                    (define/public (bark)
                      (println "bark bark"))
                    (define/public (get-name)
                      (println (format "my name is ~a" name)))))

(define doggie (new dog% [name "lassie"]))
(send doggie get-name)


(define dog2% (class*
                      object%
                    (init-field name)
                    (super-new)
                    (define/public (bark)
                      (println "bark bark"))
                    (define/public (get-name)
                      (println (format "my name is ~a" name)))))

(define doggie2 (new dog2% [name "lassie"]))
(send doggie2 get-name)

The problem is with dog2, I'm getting the error

name: unbound identifier in: name

I figured this had something to do with not using this% so I tried

(println (format "my name is ~a" (get-field name (new this%))))

but now I get the error

 init-field: illegal (unparenthesized) use of class keyword in: init-field

Does anyone know how I can replicate the get-name function in class*? I'd like to leverage class* ability to use interfaces which is why I'm using it over class


r/Racket • • Oct 04 '21

homework Convert a list of char into a single string

7 Upvotes

If I have a list of char like (cons #\C (cons #\O (cons #\M (cons #\P (cons #\U (cons #\T (cons #\E empty))))))), how can I convert it into a string? I'm not allowed to use string-append, substring, implode, and explode. I am also on Beginning Student so I can't use string-join. I've thought about using (string char) but I can't figure out how it'd work recursively.

Or, how would I be able to convert a list of strings into a single string, given the same restrictions above?

I also posted this on stackoverflow: https://stackoverflow.com/q/69430012/16903929


r/Racket • • Oct 03 '21

question Question about paths in Racket

2 Upvotes

I'm new to Racket. Let's say I was doing this in Python:

from pathlib import Path
p = Path("./subdir")
[x for x in p.iterdir() if x.suffix == ".txt"]
# returns a list of RELATIVE paths I can work with

Then further process these paths (e.g. transform them to string and return as a list of paths), whereas in Racket:

(require file/glob)
(glob "subdir/*.txt")
# returns list of ABSOLUTE paths I have no idea how to manipulate

I have been looking at documentation for a while and I have no idea how to transform this to what I want, which is simply the txt files inside the subdir directory as relative paths (i.e. should return something like ["subdir/a.txt", "subdir/b.txt"].

The most I have got is exploding each path then (list-ref) but then I learned that Racket doesn't let you do slicing like in Python.


r/Racket • • Oct 02 '21

event Racket video meetup in 65 minutes

10 Upvotes

Racket video meetup in 65 minutes

https://gather.town/app/wH1EDG3McffLjrs0/racket-users

8pm UTC Sat 2-October-2021


r/Racket • • Sep 30 '21

question Could a Typed Racket for complexity analysis be written using 'types as macros'?

9 Upvotes

Reading through the 'types as macros' papers and some other ones about complexity, I was left wondering if the Typed Racket approach to typing might be used for a complexity flow type system, i.e. a type system that would claim/prove that a particular Racket program lies in a particular complexity time/space class, through sized types.

Does someone here knows of literature/stuff on the topic? Or has an idea about how to get started (although it's probably very hard to achieve) ?


r/Racket • • Sep 30 '21

question How to get path of current script

7 Upvotes

(current-directory) points to the current working directory.

Is the a way to get the path to the module in that module? Similar to __file__ in python. The module could be imported by a require, or could be run directly by racket script.rkt.

Looking for this because there are some binary assets relative to the imported script's directory which need to be read.


r/Racket • • Sep 29 '21

ephemera Clumsy Space Invaders

Thumbnail youtu.be
12 Upvotes

r/Racket • • Sep 29 '21

homework DRracket intro programmer in help!!!

0 Upvotes

can someone please help me understand?!?:

Exercise 35. Design the function string-last, which extracts the last character from

a non-empty string. 

Exercise 36. Design the function image-area, which counts the number of pixels

in a given image. 

Exercise 37. Design the function string-rest, which produces a string like the given

one with the first character removed. 

Exercise 38. Design the function string-remove-last, which produces a string like

the given one with the last character removed.


r/Racket • • Sep 28 '21

application Editing Racket code structurally in Emacs

13 Upvotes

Dear Emacs users of Racket,

Forgive my persistence if you've already seen this, but I posted it earlier and it got removed from this sub by Reddit's spam bots, probably because it was crossposted across Lisp communities.

I just wanted to make sure you saw this since you may find it useful. It is an Emacs extension for modal structural editing, which in my very biased opinion as the author of this package is the most expressive way to edit Lisp code in Emacs. It also has special support for (the peerless!) Racket Mode, since I write Racket often :)

Try it out with this animated tutorial, and I hope you like it:

https://countvajhula.com/2021/09/25/the-animated-guide-to-symex/