racket Questions
3
Solved
I've noticed in Scheme, Racket, and Clojure that the expression (using Clojure here) (and true '()) evaluates to (), and (and '() true) evaluates to true. This is true not only for the empty list, ...
Eccentricity asked 17/11, 2016 at 17:8
1
Solved
I am trying to build the built-in procedure build-list in Racket.
The built-in function works like this:
(build-list 10 (lambda (x) (* x x)))
>> '(0 1 4 9 16 25 36 49 64 81)
My implement...
Whit asked 16/11, 2016 at 20:13
2
Solved
I found a code snippet somewhere online:
(letrec
([id (lambda (v) v)]
[ctx0 (lambda (v) `(k ,v))]
.....
.....
(if (memq ctx (list ctx0 id)) <---- condition always return false
.....
whe...
Suggestibility asked 24/11, 2015 at 1:0
3
Solved
In Common Lisp it is relatively easy to create a macro-defining macro. For example, the following macro
(defmacro abbrev (short long)
`(defmacro ,short (&rest args)
`(,',long ,@args)))
is ...
Ultrasonic asked 27/10, 2014 at 21:15
1
Solved
I am taking my first steps with exception handling in Racket and would like to write a unit test, which checks, if a procedure raises an exception for a specific input.
The following is what I alr...
Footwork asked 30/9, 2016 at 13:16
2
Solved
I found myself defining syntax parameters with identical definitions except for their name so I decided to write a macro to make this simpler:
(define-syntax (test-case-parameter stx)
(syntax-par...
Expansion asked 25/9, 2016 at 18:52
3
Solved
The following question is given in our Programming language practice exam and I am having a hard time understating how this works. Could someone tell me what the flow of code is? I have run it in r...
2
Solved
Is there any way to control how a struct is printed?
For example if I have a transparent struct containing an image:
(struct photo (label image-data) #:transparent)
But I don't want to print th...
Giroux asked 20/9, 2016 at 19:22
4
I was writing a Racket program that needed to log information but I wanted to store the logs in a file. My first attempt was to use "with-logging-to-port" and use "open-output-file" to create an ou...
Bab asked 26/8, 2016 at 12:39
1
Solved
I am using the famous book SICP. On the exercise 1.18 a strange thing happens.
I wrote this code:
(define (double n) (* 2 n))
(define (halve n) (/ n 2))
(define (fast-mult a b)
(fast-mult-iter ...
Nichy asked 25/8, 2016 at 20:47
4
Solved
In Racket (and other Schemes, from what I can tell), the only way I know of to check whether two things are not equal is to explicitly apply not to the test:
(not (= num1 num2))
(not (equal? stri...
1
Solved
I'm writing a Racket program that makes extensive use of sets. Looking at the output of the program, several of the sets include #0# as their only piece of data. What is causing this?
Montparnasse asked 22/8, 2016 at 22:17
2
Solved
In DrRacket I can set a memory limit using the GUI. However, I find the editor not sooo good and want to use another editor of my choice. But how do I specify the memory limit then?
I can think of...
1
Solved
What is the use of identity function? It simply returns the same value. Hence, instead of putting (identity x), why not simply put x? Could someone give some examples of using identity function in ...
1
I'm working on a Racket script (on a Linux machine) that requires the math/number-theory library. My entire script at the moment is thus:
#!/usr/bin/racket
(require math/number-theory)
Yes, it'...
Joni asked 21/6, 2016 at 18:38
2
Solved
Example from http://www.cse.unsw.edu.au/~en1000/haskell/hof.html :
(foldr / 7 (list 34 56 12 4 23))
(foldl / 7 (list 34 56 12 4 23))
Output in Racket:
5 193/196
5 193/196
What would be the f...
2
Solved
When generating random integers in Racket using the random function, Racket requires the argument to be a number between 1 and 4294967087. I was just wondering, where does that 4294967087 number co...
Pelton asked 10/7, 2016 at 21:40
2
Solved
Consider a scenario of two macros: the outer-macro defines a general structure of some entity, and the inner-macro expands in the scope of the outer macro. My intent is captured in the following co...
1
Solved
I'm trying to write in Racket a module meta-language mylang, which accepts a second language to which is passes the modified body, such that:
(module foo mylang typed/racket body)
is equivalen...
Murther asked 16/6, 2016 at 19:29
1
Solved
I can issue bash commands with Racket with (system "some command") , but the function returns #t instead of the resulting output from the command-line, which it only prints. How can I get the resul...
Headship asked 25/6, 2016 at 8:30
2
Solved
I've been working through the last few exercises ch 1 of SICP, where several of the exercises uses higher-order functions. Currently I'm trying to debug a problem in my solution to 1.45, which is r...
1
Solved
I am using a Google API library for Racket to try to update a Google Calendar. (The API is incomplete so I'm extending it as I go.)
I seem to have trouble with adding events to a calendar using th...
Girand asked 31/5, 2016 at 1:35
1
I just installed DrRacket, and tried out the language "How To Design Programs - Beginning Student".
Racket - A programmable programming language
Racket - Getting Started
I run (+ 1 1), and it ta...
1
Solved
I'm following the official racket example for URL-based dispatch, but can't seem to get it to work correctly.
#lang web-server/insta
(require web-server/servlet
web-server/servlet-env)
(define...
2
Solved
I'm currently learning Scheme (using Racket), but one of the challenges I'm coming upon is trying to execute the following bit of code, which is meant to execute Racket code from user input using e...
© 2022 - 2024 — McMap. All rights reserved.