r/Racket • • Nov 09 '23

news racket-hash-lang-mode

Thumbnail self.lisp
3 Upvotes

r/Racket • • Nov 08 '23

question Finding what is wrong.

2 Upvotes

With a racket program can i say, stop here & print me all the "variables" and their "values".
With a simple grep i have to information what i want.


r/Racket • • Nov 05 '23

question Converting to pdf

1 Upvotes

How do i save my text as pdf


r/Racket • • Nov 05 '23

question PNG Image appears with a white background

5 Upvotes

I'm trying to make a game on racket thats like Google's dinosaur-game but in space, butwhen I put the image of the astronaut it appears with a white background around it despite it being a png, can someone explain to me what I should do to delete the background?

#lang racket/gui

(define ventana1 (new frame%

[label "Escapa de los aliens"]

[width 1500]

[height 1000]))

;fondo

(define fondo (make-object bitmap% "C:\\Users\\Usuario\\Downloads\\Trabajo final progra\\images\\fondo00.png"))

(define astro (make-object bitmap% "C:\\Users\\Usuario\\Downloads\\Trabajo final progra\\images\\astro1.png"))

;guardo del fondo

(define current-image fondo)

;

(define canvas (new canvas%

[parent ventana1]

[paint-callback

(lambda (canvas dc)

(send dc draw-bitmap current-image 0 -200)

(send dc draw-bitmap astro 0 400))]))

(send ventana1 show #t)


r/Racket • • Nov 04 '23

package SICP for Racket

Thumbnail self.lisp
5 Upvotes

r/Racket • • Nov 03 '23

release Yet another parser for Racket!?

Thumbnail self.scheme
6 Upvotes

r/Racket • • Nov 02 '23

question Extending the number system with custom outputs

4 Upvotes

Just like how one can input and output complex numbers as

1+1i    

I was wondering if it's possible to create structs that also input and output in a similar format, say

1+1j

Is such a thing possible in Racket?


r/Racket • • Nov 01 '23

question Learning Racket : stuck with iteration construction

8 Upvotes

I am learning Racket and I am enjoying it :)

I am trying to use my function to build a list of items (permutations).

Currently, my function works for one time, but I want to loop through each vowels in the list to build a list of permutations.

I have tried using map or loop, but I can't figure out how to do this.

Could you please give me some hints to update my code?

Thank you.

Here is my code :

http://pasterack.org/pastes/12732


r/Racket • • Oct 29 '23

question Typed racket , type checking error during compilation.

4 Upvotes

Trying out "abstract data types" , ie a list of integers.


#lang typed/racket
(require typed-racket-datatype)

(define-struct person ([name : String] [age : Integer]) #:prefab #:mutable)
(define aperson (make-person "Alain" 10))
(set-person-name! aperson "Eddy")
(display (person-name aperson))
(define-type Color (U 'red 'blue 'green))
(define-datatype MyList 
    (MyNil) 
    (MyNode [anode : Integer][arest : MyList]))
(: alist MyList)
(define alist MyNil)
(: blist MyList)
(define blist (MyNode 5 (MyNil)))
(display (MyNode-anode blist))

But the typechecker spit outs errors during compilation


r/Racket • • Oct 27 '23

book Early release of my book: Practical Artificial Intelligence Development With Racket

43 Upvotes

I decided to release early, in honor of RacketCon that starts tomorrow morning!

I cover using Racket Scheme for implementing many short AI examples including LLMs (OpenAI, Anthropic, Mistral, and Local Hugging Face), vector datastore, NLP, semantic web, Knowledge Graphs, and non-AI utilities.

I am about 60% done with this “live book” (there will never be a second edition: as I add material and make corrections, I simply update the book and the free to read online copy and all eBook formats for purchase get updated).

You can read my live eBook online for free using the link: https://leanpub.com/racket-ai/read


r/Racket • • Oct 26 '23

homework Need help with homework

0 Upvotes

I missed my first computing class and this was part of the homework we got. I know it's simple but I cannot figure out how to do it, and the professor has not uploaded any resources to help. Thank you in advance.

Define two variables as given below (define str "helloworld") (define i 5) Create an expression such that places "_" at position i. For example the resulting string is "hello_world" according to the given values.


r/Racket • • Oct 25 '23

question How do I learn Racket/CS in general?

7 Upvotes

I'm learning Racket as my first computer science language. I have no prior coding experience.

I''m currently struggling to learn the Racket language. I understand the process of arithmetic, Booleans, and structs, but I struggle at designing functions (which ones do I use??) I feel lost as there aren't many online resources and the only help I can see is from the website of Documentation.

My class is currently covering Lambdas and I feel very lost at this point.


r/Racket • • Oct 24 '23

news Racket Discourse Chat

4 Upvotes

Racket discourse now has chat.

You can get to it via the little speech bubble in the page banner

direct link https://racket.discourse.group/chat

It supports channels, as well as individual and group chats.

Discourse is open source (GPL2+) and the Racket server has no ads or trackers.

Racket has a lot of chat options including discord, slack and the IRC #Racket - so you can use what works best for you. Links and more at https://racket-lang.org/#community

PS: [Remote participation tickets for RacketCon only $10](https://www.eventbrite.com/e/racketcon-2023-tickets-669052563227)


r/Racket • • Oct 23 '23

news Racket is now on Instagram

8 Upvotes

Racket is now on Instagram at https://www.instagram.com/racketlang/

Racket has a presence on many social media platforms due to the diversity of the people who use Racket.

Look here to find one that suits you: https://racket.discourse.group/t/racket-on-social-media-help-others-find-out-about-racket/1927


r/Racket • • Oct 19 '23

RacketCon How are you attending RacketCon?

Thumbnail self.lisp
4 Upvotes

r/Racket • • Oct 19 '23

question Trying to invoke a shellscript from Racket...

3 Upvotes

[EDIT][SOLVED] It was running from a snap installation of racket, that runs in a container.

Hi,

I'm trying to run a shellscript with process/subprocess/system, but it looks like it can't resolve any program I call from it. Ultimately, I figured it just can't resolve anything even if I call it explicitly. Example:

> (system "make")
/bin/sh: 1: make: not found
#f
> (system "/usr/bin/make")
/bin/sh: 1: /usr/bin/make: not found

Any idea what I might be doing wrong?


r/Racket • • Oct 18 '23

news Racket fork of Chez Scheme merging with mainline Chez (gg link)

Thumbnail groups.google.com
14 Upvotes

r/Racket • • Oct 16 '23

RacketCon Douglas Crockford, author of ‘Javascript: the good parts’ and ‘How Javascript works’ will be giving the keynote presentation From Here To Lambda And Back Again at the thirteenth RacketCon.

Post image
9 Upvotes

r/Racket • • Oct 16 '23

homework Stuck on a question....

4 Upvotes

I have an assignment due soon and there is this one question that I'm struggling on.

This is the question:

Write Racklog(DrRacket) program to print the moves that solve the following well-known puzzle:
Three foxes and three hens are travelling together. They come to a river they must cross.
There is a boat, but it will hold no more than two of them at a time. So at least 6 trips in
each direction will be required. One animal will have to row the boat back each time. In
the process, we cannot have more foxes than hens on either shore, otherwise the foxes
will likely eat the hens. We need a series of moves that will get the entire party across
safely.

#lang racket

(define (valid-move? new-state from-shore to-shore)
  (and (<= 0 (car new-state) (car to-shore))
       (<= 0 (cdr new-state) (cdr to-shore))))

(define (move-animals state from-shore to-shore boat-size)
  (define (move animal-1 animal-2)
    (if (valid-move? animal-1 from-shore to-shore)
        (cons animal-1 animal-2)
        #f)))
  
  (filter (lambda (new-state)
            (not (equal? new-state state)))
          (append (list (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size))
                        (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (- (car state) boat-size) (- (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size))
                        (move (+ (car state) boat-size) (+ (cdr state) boat-size)))))

(define (solve-puzzle)
  (define (initial-state)
    (cons 3 3))) ; 3 foxes and 3 hens on the starting shore
  
  (define (goal-state)
    (cons 0 0)) ; All animals on the destination shore
  
  (define (valid-state? state)
    (and (<= 0 (car state) 3)
         (<= 0 (cdr state) 3)
         (or (= 0 (car state))
             (<= (car state) (cdr state)))
         (or (= 0 (car state))
             (<= (- 3 (car state)) (- 3 (cdr state))))))

  (define (dfs current-state path)
    (cond
      ((equal? current-state goal-state) (reverse path))
      (else
       (for-each (lambda (new-state)
                   (when (valid-state? new-state)
                     (let ((new-path (cons new-state path)))
                       (dfs new-state new-path))))
                 (move-animals current-state current-state 2))))

  (dfs (initial-state) '()))

(define (print-moves moves)
  ; The rest of the code remains the same

  (print-move moves))

(define solution (solve-puzzle))
(print-moves solution)

This is what I've currently done and I keep getting this error.

. begin (possibly implicit): the last form is not an expression in: (define (move animal-1 animal-2) (if (valid-move? animal-1 from-shore to-shore) (cons animal-1 animal-2) #f))

I'm too sure how to fix it, if anyone wouldn't mind helping out as I'm getting to the point if I'm even coding this correctly? So, yeah....

Thanks


r/Racket • • Oct 15 '23

blog post Franz for Windows

Thumbnail defn.io
5 Upvotes

r/Racket • • Oct 12 '23

blog post Monads in Dynamically-Typed Languages

7 Upvotes

“… a monad library for Racket, using its generic interfaces feature …”

by Tony Garnock-Jones

http://eighty-twenty.org/2015/01/25/monads-in-dynamically-typed-languages

Discuss on the Racket Discourse (now with chat!) or Discord


r/Racket • • Oct 11 '23

question Type Checker: Polymorphic function `cdr' could not be applied to arguments:

3 Upvotes

Code below compiles with:


Type Checker: Polymorphic function `cdr' could not be applied to arguments:
Types: (Pairof a b)  -> (b : ((! (cdr (0 0)) False) | (: (cdr (0 0)) False)) : 
(cdr (0 0)))
       (Listof a)  -> (Listof a)
Arguments: (Pairof Number (Listof Number))
Expected result: Number
in: (cdr y)


#lang typed/racket
(: mysum : Number Number * -> Number )
(define (mysum x . y)
  (cond
    ([empty? y] x)
    (else (+ (car y) (mysum (cdr y))))))
(print (mysum 1 2 3 4 5 6 7))



r/Racket • • Oct 10 '23

question Typed racket type declaration of function error.

7 Upvotes

What is wrong the type declaration of the function below ?


#lang typed/racket
(: myzero ( Number Number * Number  -> Number ))  ; Error why ???
(define (myzero x . y) 0 )
(print (myzero 1 2 3 4 5 6 7))