Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [racket]

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

1
vote
0answers
26 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 ...
1
vote
1answer
121 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 ...
3
votes
1answer
56 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 ...
1
vote
1answer
86 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 ...
0
votes
0answers
24 views

Traversal and modification of arbitrarily nested lists

Note: this is Typed Racket; the tag does not exist and I don't have sufficient rep to create it. I am relatively new to Typed Racket, so I am interested in all improvements but especially "is this ...
0
votes
0answers
90 views

Knight-tour code taking very long time

I am trying to solve knight-tour problem using Racket. It seems to be working but it is taking a long time and I have not been able to get even one solution using this code (It reaches 62 positions ...
1
vote
1answer
100 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 ...
1
vote
0answers
161 views

Solution to N-queens problem in Racket

I am using following method to solve N-queens problem for all possible solutions for a board. It seems to be smaller as well as faster than many commonly mentioned method. Also, since it is tail-...
1
vote
0answers
97 views

Racket - temperature value converter

I'm giving myself programming challenges in various languages so that I can become a better problem solver i.e. focusing on problem abstraction and algorithm design, using various programming ...
3
votes
0answers
156 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. <...
2
votes
2answers
769 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 ...
3
votes
1answer
236 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. ...
1
vote
2answers
1k 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: ...
3
votes
1answer
141 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 ...
3
votes
2answers
111 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 ...
3
votes
1answer
435 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: ...
1
vote
2answers
1k 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 ...
5
votes
1answer
148 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 ...
1
vote
0answers
48 views

Implementation of catch test framework in Racket

As an exercise in learning how to use Racket macros I decided to implement a subset of the features in the catch test framework for C++. In particular the catch test framework has a unique feature ...
2
votes
1answer
63 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? ...
7
votes
1answer
423 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 : ...
1
vote
1answer
71 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. ...
4
votes
1answer
72 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. ...
2
votes
1answer
378 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 ...
3
votes
1answer
91 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 ...
1
vote
2answers
436 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 ...
6
votes
1answer
462 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 fill in ...
10
votes
2answers
582 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 ...
4
votes
4answers
8k 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 ...
1
vote
2answers
124 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 ...
3
votes
1answer
298 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 (...
3
votes
0answers
168 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 ...
10
votes
1answer
624 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 ...
1
vote
1answer
82 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, ...
5
votes
1answer
227 views

Simple evaluator of Scheme-like expressions in Haskell

This is my first nontrivial Haskell program: ...
3
votes
0answers
179 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 ...
2
votes
1answer
1k 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 ...
1
vote
1answer
274 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: ...
21
votes
1answer
439 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 ...
2
votes
1answer
927 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,...
4
votes
2answers
1k 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 ...
2
votes
1answer
101 views

Tridiagonal Lists in Scheme

...
6
votes
4answers
585 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 ...
2
votes
1answer
437 views

Simplifying Dr.Racket drawing code

I am using Dr.Racket, Intermediate Student with Lambda. I was wondering if there was any way I can simplify this code using any sort of method like lambda, abstraction, map, filter, etc. ...
3
votes
2answers
136 views

Simplifying Dr.Racket alien code

I am using Dr.Racket, Intermediate Student with Lambda. I was wondering if there was any way I can simplify this code using any sort of method like lambda, abstraction, map, filter, etc. ...
4
votes
2answers
418 views

Why is this RC4 code in Racket so slow?

According to shootout.alioth.debian.org, Racket is not much slower than C#, at least in the same order of magnitude due to its JIT compiler. However, I'm seeing at least two degrees of magnitude ...
1
vote
0answers
105 views

Creating an updating hash table

I'm not sure if this implementation is good enough. The function takes a vector of 1 million chars and creates a table of the sequences that pass before the next occurrence of itself. Some questions ...
4
votes
0answers
290 views

Quick Insert Merge Sort

I have written this code to sort a list of numbers, in increasing order. It is a combination of quick sort, insertion sort, and merge sort. I make the first element of the list a pivot, then I go ...
3
votes
1answer
924 views

Scheme/Racket: idiomatic infix math evaluator

Inspired by xkcd and a couple of praising blog posts, I decided to try out Lisp. It seemed that the best-supported dialect was Racket, itself a variant of Scheme, so I went with that and wrote an ...
6
votes
1answer
777 views

Improving a priority queue sketch in Racket/Scheme

I just put together the skeletons for a priority queue using a binary heap in racket/scheme. Using racket/scheme is all about the educational experience and I was wondering if anyone wants to ...