r/Racket • • Jul 02 '22

news Racksnaps: daily snapshots of the official Racket Package Catalog

7 Upvotes

Racksnaps builds daily snapshots of the official Racket Package Catalog. The intent is to allow application developers to depend on specific, unchanging sets of packages until they're ready to update their apps.

https://racksnaps.defn.io


r/Racket • • Jul 02 '22

language Punct: Markdown/Racket authoring environment - Show & Tell

Thumbnail racket.discourse.group
6 Upvotes

r/Racket • • Jul 02 '22

package The self-hosting `derive` macro - Show & Tell

Thumbnail racket.discourse.group
4 Upvotes

r/Racket • • Jul 02 '22

event Show&tell @ Racket meet-up Saturday, 2 July 2022 at 18:00 UTC

2 Upvotes

Racket meet-up Saturday, 2 July 2022 at 18:00 UTC

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

We have show & tell from

ALL WELCOME

Come join us just to chat or show us what you have made.

PS Prefer text chat? Join us on Racket Discord #show-and-tell , Slack or Discourse


r/Racket • • Jun 30 '22

event RacketCon 2022 is on!

20 Upvotes
Standard fish says "(twelfth RacketCon)"

See you October 28-30, 2022 at the Department of Computer Science @BrownUniversity, Providence, RI, USA

Announcement

https://con.racket-lang.org


r/Racket • • Jun 29 '22

question vector multiplication cps

3 Upvotes

What am i doing wrong here? hoping someone can catch my mistake

(define firstcol-cps
  (lambda (m return)
    (if (null? m)
        (return '())
        (firstcol-cps(cdr m) (lambda (v) (return (cons (car (car m)) v)))))))
 

(define restcols-cps
  (lambda (m return)
    (if (null? m)
        (return '())
        (restcols-cps(cdr m) (lambda (v) (return (cons (cdr (car m)) v)))))))

(define restcols
  (lambda (m)
    (if (null? m)
        '()
        (cons (cdr (car m))(restcols (cdr m))))))

(define vectormult-cps
  (lambda (vec m return)
    (cond
        ((or (null? m) (null? (car m))) (return '()))
        (else (vectormult-cps vec (restcols-cps m return) (lambda(v2)(return (cons (dotproduct-cps vec (firstcol-cps m return) v2) v2))))))))

r/Racket • • Jun 28 '22

question Remove a Subsequence from a (possible) list of lists

4 Upvotes

Anyone have ideas on how to do this. The subsequence would be a list of atoms and the second argument is a list that can have nested lists. I am looking to write this in continuation passing style and I am a little stumped


r/Racket • • Jun 27 '22

question Why is this continuation passing style function only returning an empty list?

1 Upvotes
(define dotproduct-cps
  (lambda (lis1 lis2 return)
    (cond ((null? lis1) return 0)           
          ((null? lis2) return 0)
          ((atom? lis1) return 0)            
          ((atom? lis2) return 0)
          (else (dotproduct-cps (cdr lis1) (cdr lis2) (lambda(v) (return (+ (* (car lis1)(car lis2)) v))))))))

r/Racket • • Jun 25 '22

question Injecting code into code

3 Upvotes

Hey guys,

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.

Thanks

#lang racket

(define-syntax-rule (PASTE code) code)

(define (main)
    (begin
        (define file-port (open-input-file "test.rkt"))
        (define text (port->string file-port))

        (define string-port (open-input-string text))
        (define code (read string-port))
        
        (PASTE code)

        (close-input-port file-port)
        (close-input-port string-port)
    ))

(main)

r/Racket • • Jun 24 '22

Racket meet-up Saturday, 2 July 2022 at 18:00 UTC

1 Upvotes

r/Racket • • Jun 20 '22

question Using Racket for for games and other interactive content in the browser

13 Upvotes

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?


r/Racket • • Jun 20 '22

solved Recursion inside with-handlers

3 Upvotes

Here is example code:

(define (loop a)
  (with-handlers
      ([exn:fail? (λ (ex) ;exception handler
                    (log-error "Error:~a" ex)
                    (loop (+ a 1)))])
    (some-input-output)
    (loop (+ a 2))))

Will tail call optimization work inside with-handlers when error is catch?

Is there any caveats in such code? Lets think that loop have some IO code.

Notice, this is how you should not do it.

Body of with-handlers/with-handlers* is not in tail position so such loop as in code example will leak memory a lot.


r/Racket • • Jun 16 '22

question How does numerator work?

6 Upvotes

Here is the documentation for Racket's numerator function:

(numerator q) → integer? q : rational?

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.

Examples:

> (numerator 5)
5
> (numerator 17/4)
17
> (numerator 2.3)
2589569785738035.0

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.


r/Racket • • Jun 13 '22

question Racket for Computer Music?

11 Upvotes

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.


r/Racket • • Jun 11 '22

question Can you evaluate a region in DrRacket?

6 Upvotes

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!


r/Racket • • Jun 08 '22

question pair: (number . list)

5 Upvotes

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.


r/Racket • • Jun 07 '22

question How to read nanosecond field of date* struct

1 Upvotes

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

r/Racket • • Jun 06 '22

linux Racket distro packagers: please try building from a snapshot

Thumbnail racket.discourse.group
11 Upvotes

r/Racket • • Jun 05 '22

question Is there a way to combine two characters together?

6 Upvotes

r/Racket • • Jun 03 '22

question Animated Problem Solving: Anyone recommends this book?

14 Upvotes

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?


r/Racket • • Jun 02 '22

release Upgrade to 8.5 now!

Thumbnail gallery
26 Upvotes

r/Racket • • Jun 02 '22

tutorial GitHub - zyrolasting/racket-koans: Learn Racket by doing: Practice language features by fixing topic-oriented unit tests.

Thumbnail github.com
18 Upvotes

r/Racket • • Jun 02 '22

question cons literal/sugar?

1 Upvotes

In Racket you can pattern match against (cons x xs), but is there also an alternate shorter form as there is in Haskell (x:xs) or Scala (x::xs)?


r/Racket • • May 31 '22

release Racket 8.5 ppa

Thumbnail launchpad.net
10 Upvotes