As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [racket]

Racket is an extensible multi-paradigm programming language in the Lisp/Scheme family.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Function definition and function call input seem coherent, but there's an error about the input when the application runs. What's wrong?

A novice in programming here (also first time posting here), trying to solve ex.91 from the htdp book (in racket - beginner student language). There's trouble with a helper function, which I named '...
candleconch's user avatar
0 votes
0 answers
29 views

How to make a list of atoms from a generic list in racket? [duplicate]

I basic have this code where I try to make a list of unique atoms from a list of lists of lists etc but my code doesn't seem to have any effect on the given lists, what could be wrong ? How to fix it? ...
Lucas Lima's user avatar
0 votes
1 answer
66 views

How to return either a multiplied value in a list or boolean in Scheme (R5RS)?

So I encountered a problem where I have a list of numbers that I need to multiply out and return that value. However, if the list does not contain numbers or is an empty list, return false. Please ...
UnknownPeach's user avatar
0 votes
3 answers
49 views

Is it possible to use 'append' or 'cons' to create a make-list function in Scheme that repeats values based on a given size parameter?

Is there an alternative way of writing the make-list function in Scheme (R5RS)? I am trying to create a function where the value repeats itself in the list based on the given size. So my expected ...
UnknownPeach's user avatar
1 vote
1 answer
34 views

DrRacket - render every structure in a list

(define SCENE (empty-scene 500 500)) (define-struct pos (x y)) (define-struct ball (img pos)) ;(define (render lst)) (define game (list (make-ball (circle 10 "solid" "...
tim123908's user avatar
0 votes
0 answers
47 views

Should I send X-expressions over the wire, or should I compile down to XML

I'm writing a program that will send something similar-ish to HTML over the internet. The way my program represents the data is through X-expressions. Should I send the raw X-expression over the wire, ...
reesericci's user avatar
1 vote
1 answer
79 views

Extracting data of pairs without the data that encountered before

I have a data which inside of some pairs. But some pairs go a pair that encountered before. I don't want to extract same data again. For example I have a data like this. So, as you see p3's first item ...
Emirkan's user avatar
  • 25
0 votes
2 answers
26 views

Racket lexer greedy selection

I am trying to write lexer with racket , and I am using parser-tools/lex and parser-tools/lex-sre. and I would like to create Token for strings - but Because the lexer selection is not greedy if I ...
IDANG's user avatar
  • 11
0 votes
1 answer
37 views

How to parse string to list in typed racket

I am working on writing a simple parser in typed Racket, and as part of it, I want to parse string representations of s-expressions to lists as follows: "(+ 1 (/ 2 (inc 0)))" => (list '+ ...
Someone's user avatar
  • 800
0 votes
0 answers
50 views

Racket thinks that a macro application is a function application

I am working on a racket project and as part of it, I want to encode certain arithmetic operations as integers. To avoid repeating myself, I have tried to make a couple of macros that automatically ...
Someone's user avatar
  • 800
0 votes
1 answer
39 views

how can i get out of this loop?

(define (desplazamiento a b c) (cond ((equal? c #t) (begin ((draw-solid-rectangle ventana) (make-posn a b) 40 40 "blue") (sleep 0.5) ...
Juan Agudelo's user avatar
2 votes
2 answers
118 views

Passing a list of lists by value is not updating in Scheme language

I am trying to write a function in Scheme which will calculate the rank of a given matrix (in the form of a list of lists) using Gaussian Elimination method. I'll explain what I am trying to do in the ...
SA.93's user avatar
  • 141
0 votes
2 answers
38 views

How do I convert a list written on a text field from lstring to list?

I'm not an English native, so if there are any mistakes, please correct me. I have written a program that takes an arithmetic expression and reduces it. It takes a list and returns a list like this ...
louberlu's user avatar
1 vote
0 answers
43 views

adding Array to "LET" language

I have the "LET" language from the book "EOPL" you can see also the defention of the lang in the following git: https://github.com/svenpanne/EOPL3/blob/master/chapter3/exercise-3-...
Dani Dubinskey's user avatar
0 votes
0 answers
34 views

immutable? function not defined in Racket

I was reading the racket documentation about strings and came across the immutable? function. I tried to use it on racket but it didn't work. It says it's not defined. I'm using beginner student whit ...
Agustín Blando's user avatar
1 vote
0 answers
34 views

How to convert a language to lists, Racket

I am making a parser in racket and I have the following error map: contract violation ; expected: list? ; given: (language:lenguajito '(& varmain1 varmain2)) ; [,bt for context] I understand ...
Erick Bernal Márquez's user avatar
0 votes
1 answer
47 views

How to get the arguments of an instance of a Scheme define-type?

I have a stripped-down define-type of a function definition: (define-type FunDef (fundef (fn-name symbol?))) Here is a function definition which satisfies the define-type: (fundef 'f) How do I ...
Roger Costello's user avatar
1 vote
1 answer
63 views

Scheme is not able to identify define-macro

I'm following Prof. Harvey's cs61a and among the files made available, there is one that implements Object Oriented Paradigm (here). When loading it to Dr. Racket and adding the simply-scheme language ...
Dan's user avatar
  • 135
1 vote
1 answer
46 views

How to make DrRacket give me exact numbers as fractions and not decimals?

I'm currently working with the beginning student language in DrRacket while reading through a book called "How to design programs". Currently if I type something like (/ 1 2) I get 0.5 as ...
zlaaemi's user avatar
  • 113
0 votes
0 answers
24 views

Nesting 'define' functions in another function in PLAIT, racket

Is it possible to define function inside another function in plait? When I do it in Racket it works well but in plait I keep getting errors. Here is an example: (define (fact n) (define (it-fact n) ...
hsuacria's user avatar
1 vote
3 answers
91 views

A let in a cond in scheme possible?

I have a problem I don't understand how let works in a cond, with an if I understand it but not with a cond... Here's my code with a let: (define add2 (lambda (l) (cond ((null? l) l) (let (...
BaaRai's user avatar
  • 13
0 votes
0 answers
61 views

Expected Procedure Error from Function that Should Expect Boolean

So I am trying to write a function that iterates through a list of points and counts the number of points that are less than a certain distance from a given plane. My issue is that I am getting the &...
tragicstudent's user avatar
0 votes
1 answer
37 views

Some 2htdp/image functions are not working

I was following along with my racket practice when i tried drawing a circle and got an error. #lang racket > (square 40 "solid" "slateblue") square: this function is ...
Agustín Blando's user avatar
0 votes
0 answers
35 views

Highlight active parenthesis pair in vs code

How can I make vs code highlight inside a pair of parenthesis when put cursor at one of the parenthesis (this is drracket editor)
WestMountain's user avatar
1 vote
3 answers
174 views

Flattening a list of lists in racket

I'm working on an assignment in Racket (Intermediate Student with lambda) and I'm trying to make a helper function which flattens a list of lists. I'm not allowed to use recursion, nor can I use apply....
glass's user avatar
  • 11
0 votes
2 answers
62 views

Flip the elements of slist in Racket

I want to define a function flip that flips 'i' to 'o', 'o' to 'i', 'z' to 'n' and 'n' to 'z'. for example: (flip '(i i o n)) → '(o o i z) I have the following codes: (define (flip s) (cond [(eq? ...
Mersennemath's user avatar
-1 votes
1 answer
115 views

Racket REPL: what does the statement "string::<value>: read:...." refer to when I load my .rkt file into Racket REPL, and how do I fix it?

I am working with a .rkt file in VSCodium, using the Magic Racket extension. File Contents: #lang racket (define (square x) (* x x)) (define myNums (list 1 2 3 4 5)) (define hisNums '(2 4 6 8 10 9 7 ...
nutbunny's user avatar
1 vote
1 answer
27 views

Create a Racket prop:custom-write that prints like #:transparent

I have written the following struct definition: > (require racket/struct) > (struct/contract foo ([bar (listof number?)]) #:property prop:custom-write (make-constructor-style-printer ...
Nate's user avatar
  • 12.5k
0 votes
0 answers
30 views

racket pollen: create outputs in different languages

In the racket pollen language, it is possible to define a template for generating an output in a given format (for example html). Let's imagine I want to create a webpage in multiple languages (...
MohamedLEGH's user avatar
0 votes
1 answer
57 views

Why does (read) just set the delimiters to parentheses and then precedes the expression with a backtick?

Scheme (Racket) newbie here. I am reading this book: Programming Languages Application and Interpretation by Shriram Krishnamurthi. I installed the plai package. On page 7 the book talks about (read) ...
Roger Costello's user avatar
1 vote
1 answer
54 views

Local defines in R5RS Scheme language in DrRacket

When I write the following code with two local defines in DrRacket using the #lang r5rs language standard I get an error: (define (f) (define a -8) ;a (define b a) (display b)) (f) It ...
Kim Mens's user avatar
  • 325
1 vote
1 answer
48 views

racket slideshow: how to display in a window (and not fullscreen)?

When I run slideshow, it automatically run in full screen. I searched in the options but I can't find anything to display slideshow in a window. Any ideas ?
MohamedLEGH's user avatar
-1 votes
1 answer
47 views

racket slideshow image specify size

In racket slideshow, it is possible to include an image with the bitmap command, like this: #lang slideshow (slide #:title "Presentation" (t "Introduction") (bitmap "image....
MohamedLEGH's user avatar
0 votes
0 answers
33 views

How to get the Racket command line to display an expression that is preceded by a backtick?

Scheme (Racket) newbie here. I am reading this book: Programming Languages Application and Interpretation by Shriram Krishnamurthi. I installed the plai package. The book has this define-type on page ...
Roger Costello's user avatar
0 votes
1 answer
35 views

Must a colon separate an id and a type? Is a type with a question mark no longer acceptable?

Scheme (Racket) newbie here. I am reading this book: Programming Languages Application and Interpretation by Shriram Krishnamurthi. I installed the plai-typed package. The book has this define-type on ...
Roger Costello's user avatar
0 votes
0 answers
41 views

What do I tell Racket for it to allow me to use define-type?

Scheme (Racket) newbie here. I am trying to run some of the programs in this book 1 I am on a Windows 10 machine. I downloaded Racket from here (https://download.racket-lang.org/) I started up Racket....
Roger Costello's user avatar
1 vote
1 answer
82 views

racket pretty print json

This is what I'm using to pretty-print json (calling the jq command): #lang racket (require racket/string) (require racket/system) (define (pretty-print-json json_str) ; for escaping '\' and '"...
MohamedLEGH's user avatar
0 votes
1 answer
66 views

lambda function to omit value on a list

I am wondering if there is any way to write a lambda function(recursively?), that omits certain value(it's every occurence) on a given list? I tried come up with an idea, but the whole thing breaks ...
viGor027's user avatar
0 votes
2 answers
41 views

manual compostion of two functions

I try to make my own (compose) function, but I can't get through it. It needs to work as follow: let's call that function "manual" - manual needs to take two arguments, and it has to compose ...
viGor027's user avatar
0 votes
2 answers
54 views

How can I hash-map keys and values recursively to a list in Racket?

I'm trying to replace the elements of a list that equal to the keys of the hashmap with the corresponding values. Here is what I tried: #lang racket (define my-hash (make-hash)) (hash-set! my-hash 'a ...
Bryan's user avatar
  • 3
0 votes
1 answer
66 views

Why is my Parser written in Racket Brag exceeding 128 MB memory limit

I'm writing an esolang I designed (called RifL) in Racket using the beautiful racket textbook. I'm 99% done, and was testing RifL by writing a larger program in it. When the RifL program got large ...
Jesse Hamlin-Navias's user avatar
0 votes
1 answer
21 views

no value found after parsing json file in Racket

I have the following code: #lang racket (require json) (define test-json (read-json (open-input-string (file->string "test.json")))) (hash-ref test-json "foo") test.json { ...
yFlix's user avatar
  • 13
0 votes
1 answer
107 views

Trying to make a lexer using Beautiful Racket

I am new to Racket and I am trying to tokenize a grammar using the Beautiful Racket library. I have defined the grammar in a separate file and it seems to be completely fine. I have also created a ...
Flurrshify's user avatar
0 votes
2 answers
120 views

How can cond from Racket be written using only logcal operators?

For my homework, I need to write a recursive function without any conditional statements, only logical operators and I don't have any idea how to write cond using only logical operators. Can someone ...
Maria Chirnogeanu's user avatar
0 votes
0 answers
38 views

Racket: does "prefab" structure type allow for automatic JSON serialization?

I have a question about JSON serialization and prefab struct. Is it possible to automatically serialize a prefab struct into a JSON or do I need to do it myself ? For example for this example below, ...
MohamedLEGH's user avatar
0 votes
1 answer
35 views

Racket: does "prefab" structure type give a "to_string" method?

I'm starting coding in the racket programming language. I would like to know how much prefab brings compared to "transparent". The documentation is not very explicit on this subject. In ...
MohamedLEGH's user avatar
0 votes
2 answers
49 views

Recursive Function Not Outputting the Computation

I've got to write a function that goes through sub-lists in a list and takes the first element in each one. I think I've got the solution right but I just don't get why it triggers my base case ...
Jaydn Hunte's user avatar
1 vote
1 answer
71 views

How to use map with a list of lists

I am needed to use map on a list of lists in Scheme (Racket). What I want specifically is something like (map-lists add1 '((3 1) (2 8))) => '((4 2) (3 9)). I know how to solve this recursively, ...
cfrost6's user avatar
  • 13
0 votes
1 answer
32 views

Selecting Elements from a List in Racket

I have a function in Racket which takes a list, iterates through it, checks each item in the list against a condition, and is intended to output a list of the index of every item for which this ...
JaySay's user avatar
  • 35
-1 votes
1 answer
39 views

hash-keys : contract violation in racket

I have written the following function (define (mk-initial-pagerank graph) (let* ((pages (remove-duplicates (apply append graph))) (num-pages (length pages))) (let loop ((i 0) (pr '())) (if (= ...
poojan desai's user avatar

1
2 3 4 5
116