Skip to main content

Questions tagged [racket]

Racket is an extensible general programming language in the Lisp family.

Filter by
Sorted by
Tagged with
2 votes
1 answer
98 views

Brute-force algorithm to solve allocation/assignment in Racket

The situation: A certain number of kids come to a library and each of them wants to borrow a book. Since there is only one copy of each book in the library, each child must say which book they would ...
trunklop's user avatar
  • 123
3 votes
1 answer
36 views

Wide-stripes function in Racket

The exercise is asking to make wider stripes similar to the previous exercise. I've included the exercise and code from it along with code that I've been messing with to get the desired result. I know ...
Wondering Minds's user avatar
0 votes
1 answer
94 views

Why is this racket n queens code so inefficient?

I have the following code for the n queens problem described here: https://leetcode.com/problems/n-queens/ ...
zendevil.eth's user avatar
1 vote
0 answers
111 views

Simply Scheme book: "functions.scm", How to use basic language constructs to create interactive prompt for function application

While reading Simply Scheme by Brian Harvey and Matthew Wright: Part I: Chapter 2 Functions In this chapter you are going to use the computer to explore functions, but you are not going to use the ...
RacketeerHaskeller's user avatar
3 votes
2 answers
412 views

Tower of Hanoi in Racket

I'm in the early stages of learning Racket, and decided to have a go at the tower of Hanoi. I did this without any reference whatsoever, so everything is up for review, including the algorithm as well ...
Avrohom Yisroel's user avatar
1 vote
1 answer
37 views

Racket code to find missing ranges

I'm doing some toy problems in a variety of languages and wanted to do the following in Racket Lisp. Given a sorted integer array nums, where the range of elements ...
George Mauer's user avatar
  • 1,652
1 vote
0 answers
87 views

Is this zip function ok?

A slick way to write the zip function in Scheme/Racket: (define (zip . lsts) (apply map list lsts)) (zip '(a b c) '(1 2 3)) '((a 1) (b 2) (c 3)) Is using cons ...
X10D's user avatar
  • 119
-1 votes
1 answer
70 views

Is this OR procedure correct? [closed]

...
X10D's user avatar
  • 119
1 vote
1 answer
502 views

Implementations of unzip in Racket

I've been practicing my folds and tail-call recursive programming, and I wanted to work on unzip for the general case as opposed to just pairs. This was very easy ...
BrainFRZ's user avatar
  • 819
2 votes
0 answers
148 views

Sum of matrix region in racket

I'm learning racket and did simple code challenge in a literate programming style with org mode The problem: Given a matrix of integers and the top left and bottom right coordinates of a ...
George Mauer's user avatar
  • 1,652
1 vote
0 answers
649 views

Cartesian product in racket (Is append-map okay?)

I've read several places that say it's really bad to use append, and I understand why. I read somewhere that it was never even correct to use ...
BrainFRZ's user avatar
  • 819
3 votes
0 answers
126 views

Racket macro for variadic FFI

I'm working on FFI wrapper for SDL2 library in Racket. The library includes several variadic functions (e.g. SDL_SetError, SDL_LogMessage etc); Racket FFI does not have straight way for importing ...
Andrew Kravchuk's user avatar
2 votes
0 answers
698 views

Simple web API that access sqlite database

This is a very simple web API for a school assignment, as a part of a bigger system. The web API returns a list of courses or a single course as json. I doubt that I will get any feedback on the code ...
paraplyet's user avatar
1 vote
1 answer
3k views

Binary search tree insertion in Racket

I am learning Racket and implemented a BST insert function (insert tree n) where the format for a BST node is ...
user9302738's user avatar
4 votes
1 answer
131 views

Recamán's Sequence in Racket

I just started learning Racket as my first lisp dialect so after getting used to the syntax I implemented the Recamán's sequence. Apart from the style, I'd also like to know if my code is a linear ...
xenthreaded's user avatar
1 vote
1 answer
822 views

Stack calculator in Racket

I have implemented a stack calculator based on this programming task. I wondered if a more experienced racketeer could give me feedback and tell me if I am missing anything in Racket that would enable ...
Tom Lukeywood's user avatar
1 vote
1 answer
194 views

Permutation-stream based n-queens solution

Following is a very crisp solution for solving n-queens problem in Racket programming language. The method is to get all permutations (so that no 2 queens are in same line) and to check these for any ...
rnso's user avatar
  • 241
3 votes
0 answers
677 views

Knapsack solution in Scheme/Racket

Following is my solution to Knapsack problem using all combinations of the sent list of items (in Racket programming language). Although it is very short, I am sure it can be improved in many ways. <...
rnso's user avatar
  • 241
3 votes
2 answers
3k views

Sudoku solver in Racket

I have written following code to solve Sudoku puzzles in Racket (a Scheme/Lisp derivative programming language). Following relatively simple code appears to work but are there any bugs in it or can it ...
rnso's user avatar
  • 241
3 votes
1 answer
296 views

Advent of Code 2016 Day 1 "No Time for a Taxicab"

I already solved it in JavaScript, where I'm more comfortable. I pretty much ported the algorithm from there. I wanted to try the first Advent of Code puzzle in a new language and I picked Racket. ...
joews's user avatar
  • 133
1 vote
2 answers
11k views

Highest number in a list with Racket

I am trying to build a function to find the highest number in a list without using the built-in functions of "apply" and "max". I created the following code: ...
user avatar
3 votes
1 answer
330 views

Simplifying Macro-Generating Racket Macro

I'm trying to write a small macro library in Racket that extends a few of the racket/match functions I use, by printing which clause was expanded. While this seems ...
user avatar
2 votes
2 answers
202 views

GUI implementation with Racket

I am studying the book Realm of Racket. On chapter 5, there is a challenge: Find an image of a locomotive. Create an animation that runs the locomotive from just past the left margin to just past ...
user avatar
3 votes
1 answer
832 views

Tic-Tac-Toe game with AI

I started learning Racket recently and decide to revisit the problem that introduced me to computer programming: making a Tic-Tac-Toe game with AI. Here's the code: ...
SlySherZ's user avatar
  • 131
1 vote
2 answers
8k views

Reverse the order of a list in Racket

I am using the SICP book. There is an exercise in which you need to create a function that will receive a list as an argument and return a list with the same elements in a reverse order. I know there ...
user avatar
5 votes
1 answer
327 views

“Guess My Number” with Racket

I am using the book "Realm of Racket" which was written by the people behind the Racket and Dr. Racket projects. It is a great book based on games, similar to the famous "Land of Lisp". The first ...
user avatar
2 votes
1 answer
77 views

Evaluation of e^x with series expansion

My code calculates \$e^x\$ with series expansion. Is there any way to make it shorter and cleaner? ...
fluter's user avatar
  • 121
7 votes
1 answer
691 views

Doge meme generator in Racket

I wrote a doge meme generator in racket some time ago, mainly as a joke, and I would like some criticism about the general style and what could be improved. Here is how the program output looks : ...
Hello_world's user avatar
1 vote
1 answer
87 views

Functional coffee dispenser [closed]

Inspired by this question, I decided to rewrite this code in Scheme, as I'm working through SICP right now. Any feedback welcome. ...
Racheet's user avatar
  • 217
4 votes
1 answer
114 views

Introduce bindings for macro user

I'm doing the Racket track on exercism.io and solved the grains exercise: Write a program that calculates the number of grains of wheat on a chessboard given that the number on each square doubles. ...
user avatar
2 votes
1 answer
745 views

Mutable stack in Racket

I'm learning Racket and have implemented a mutable stack, which is just a bunch of wrappers around an underlying struct containing a size and buffer list (so it's ...
Xophmeister's user avatar
3 votes
1 answer
112 views

in-nest-sequence: sequence generator in Racket

in-nest-sequence is a sequence generator that takes a function and an initial value, and the return value of invoking the function on the current value is used as ...
C. K. Young's user avatar
  • 2,342
1 vote
2 answers
825 views

Project Euler #12 in Racket

Problem here. It's not exactly the brute force approach but I'm not using any sort of pre-calculated primes table, and I'm definitely not using the coprimality trick shown in the PE pdf. I'm finding ...
user avatar
6 votes
1 answer
644 views

Binero puzzle solver

During my holiday I decided to implement a solver for those puzzles my girlfriend likes to do. They are called Takuzu, but "binero" in Dutch. The puzzle gives you a grid in which you have to ...
Christophe De Troyer's user avatar
10 votes
2 answers
1k views

Number guessing game in Racket

I decided to learn a Lisp-ish language and I am discovering a very weird and new syntax. The obligatory first program, that also uses all the fundamentals, is the number guessing game. Did I define ...
Caridorc's user avatar
  • 27.5k
4 votes
4 answers
16k views

Splitting a list in Racket

I am working my way into learning a bit of Scheme (actually, Racket) with the help of a few practical problems to solve. In this case, I want to split a flat list of symbols at a certain delimiter ...
Stefano Sanfilippo's user avatar
3 votes
2 answers
253 views

Solution to Project Euler #1 - multiples of 3 and 5

I have been programming for about ~2 years, and mostly wrote OOP and structural code. Recently, I have decided to pick up a functional programming language, and Haskell being too alien for me, looked ...
DTSCode's user avatar
  • 193
3 votes
1 answer
505 views

Digit Summing Function

I'm working through the common divisibility tests, and implementing them in Racket. I'm working on divisible by three, for which I thought it'd be nice to keep summing until I got to a single digit (...
upasaka's user avatar
  • 241
3 votes
0 answers
185 views

Graphical editor with geometric intersection

If it is possible I would like some comments on the overall style of the program. It feels like I am writing the whole program as one big script and I'm not sure how to break it down into several ...
KRC's user avatar
  • 143
10 votes
1 answer
878 views

WebSocket-based API library in Racket

I've developed a library in (typed) Racket that wraps a WebSocket-based API. The API itself is very simple—it operates via a series of three-letter commands optionally followed by a JSON-encoded ...
Alexis King's user avatar
  • 3,172
1 vote
1 answer
177 views

Extracting values from a list

I had already solved this problem, but in an unnecessarily convoluted way that seems too specific. Can this be done better? From a list: (8 "layer-name" 10 x1 20 y1 10 x2 20 y2 10 x3 20 y3) 8, ...
KRC's user avatar
  • 143
5 votes
1 answer
305 views

Simple evaluator of Scheme-like expressions in Haskell

This is my first nontrivial Haskell program: ...
Richard Cook's user avatar
3 votes
0 answers
200 views

Calculating continued fraction expansions (without requiring arbitrary precision decimals)

I'm writing a program that will compute a continued fraction expansion of a number. I've been learning Racket/Scheme for a few weeks and I wanted to see what I can do better. Usage: This program ...
Chris Brooks's user avatar
2 votes
1 answer
2k views

Finding the subsets of a set

I am trying to write a procedure that finds the power set of a list, that is, the set of 2n subsets (where n is the number of elements in the list). I simply quite find all the subsets. I feel my code ...
user3450695's user avatar
1 vote
1 answer
512 views

Reading/writing null-terminated strings from socket

I need to handle C style ('\0' delimited) strings from/to a socket and came up with this as a first attempt: ...
user avatar
23 votes
1 answer
562 views

Is this IRC bot utility library Racket-y enough?

To help myself learn Racket, I ported a simple JavaScript ircbot module I wrote for Node.js to Racket. The Racket version is built atop the Racket irc package, so ...
Alexis King's user avatar
  • 3,172
2 votes
1 answer
1k views

Solving the N-queens puzzle the Racket or Scheme way

My final version is a direct translation from Python. Thanks to build-in support for generator, its speed is almost the same as Python. As I quite like using generator and list comprehension in Python,...
xiang's user avatar
  • 23
4 votes
2 answers
2k views

Converting English Measurements to Metric and vice versa

I finished answering Exercise 3.3.1 of How to Design Programs where: Exercise 3.3.1. The United States uses the English system of (length) measurements. The rest of the world uses the metric ...
exilyte's user avatar
  • 41
2 votes
1 answer
105 views

Tridiagonal Lists in Scheme

...
Hassan's user avatar
  • 23
6 votes
4 answers
682 views

Project Euler 1 (sum of multiples of 3 or 5 under 1000)

I solved this a while ago. In the moment I solved it I was learning Scheme and, well, I still am. I'm not looking at the best solution (I searched for it and coded it already, in Python), what I want ...
ArthurChamz's user avatar