Questions tagged [common-lisp]

Common Lisp, or ANSI Common Lisp, is a standardized version of the Lisp programming language intended for production-strength power and libraries.

Filter by
Sorted by
Tagged with
3 votes
0 answers
56 views

Prime number generator in lisp

My implementation is based on the incremental prime sieve described on Wikipedia. I'm relatively new to lisp so I would appreciate any comments on my coding style or on the algorithm. The below code ...
user avatar
  • 305
1 vote
1 answer
38 views

How can I make this check balanced parenthesis implementation more concise and efficient?

I'm new to common lisp. I basically translated a procedural implementation of balanced parenthesis using a stack to common lisp. How can I make my implementation more lispy? ...
user avatar
  • 11
1 vote
1 answer
44 views

Break down a list SEQUENCE into consecutive lists of constant TASTE

I am looking for ways to improve this little utility function: ...
user avatar
0 votes
0 answers
24 views

Constructing Functions Patterned After Common Lisp Built-in Functions

This is an experiment to see what's involved in adding new functional capability to the Common Lisp baseline. In this case, it's adding a sequence function to select elements from a sequence ...
user avatar
  • 405
2 votes
0 answers
45 views

S-expression comments in Common Lisp

I have written a Common Lisp implementation of Scheme's s-expression comments (SRFI 62): ...
user avatar
  • 371
3 votes
0 answers
20 views

Detecting Dependencies in Common Lisp Project Files (Part 2)

This is a rewrite of the Dependencies program submitted previously at https://codereview.stackexchange.com/questions/255635/detecting-dependencies-in-common-lisp-project-files/256336?noredirect=1#...
user avatar
  • 405
2 votes
1 answer
69 views

Detecting Dependencies in Common Lisp Project Files

The following short program is a collection of routines for detecting the dependencies among a project’s component files. Dependencies serve as a rough measure of the complexity of a program. ...
user avatar
  • 405
4 votes
1 answer
46 views

Count complete trips to the basement and back to ground floor

An elevator starts on the ground floor 0 and moves up or down by one floor at a time as described by an input string travel. ...
user avatar
4 votes
1 answer
56 views

count pairs of matching integers in a collection in Common Lisp

This defines count-pairs which takes a collection of integers returns the number of pairs of integers that are equal to each other. If the input collection has ...
user avatar
3 votes
1 answer
223 views

Deque class in Common Lisp

I created a library with two CLOS class to implement a deque structure similar to the one available in C++, plus a few Lisp-ian twists. The two classes are node, ...
user avatar
2 votes
0 answers
45 views

Lispy code? Palindrome of product

My answer to Project Euler problem 4 (largest palindrome of product of two 3-digit numbers) is below. Please suggest improvements, style changes, indentation, commenting, naming, ... And nitpicks are ...
user avatar
  • 520
2 votes
2 answers
101 views

Lispy code? Prime factors of a number

My answer to Project Euler problem 3 (largest prime factor of 600851475143) is below. Please suggest improvements, style changes, indentation, commenting, naming of "objects", ... ...
user avatar
  • 520
3 votes
1 answer
145 views

Lispy code? Sum multiples of 3 or 5 up to 1000

I've started learning Lisp one more time (I seem to do this every couple years); my experience is with C, basically. I attempted to solve the Project Euler problem 1: If we list all the natural ...
user avatar
  • 520
3 votes
0 answers
43 views

My solution to the 100 prisoners challenge

I stumbled across the 100 prisoners problem on Rosetta Code. I thought it would be fun to add a Common Lisp solution, see below. Before I publish my solution I would like to have some feedback on my ...
user avatar
4 votes
0 answers
174 views

Hunchentoot first steps - good ways of pulling out parenscript from an easy-handler

In the following hunchentoot easy-handler definition: ...
user avatar
  • 483
4 votes
0 answers
91 views

Thoughts about a json2clos decoding using cl-json

Coming from this question https://stackoverflow.com/questions/58131614/how-to-convert-json-string-into-complex-clos-object-using-cl-json-library I've finally come up with the following solution. I ...
user avatar
1 vote
0 answers
47 views

BST range search

I'd like some input on my implementation of bst-range, which follows below. Before we can get to bst-range, we first need some setup code to build the BST. (You ...
user avatar
  • 483
6 votes
1 answer
63 views

BST with node count

I took a simple BST implementation which is only really a set (i.e. just element, not key value), and decided to add a node count. I was translating this, which is explained here. In particular the ...
user avatar
  • 483
1 vote
1 answer
41 views

Generating HTML for prerolled d20 RPG initiative tables

A fairly simple program that I tried to write in Common Lisp in order to practice/learn. I'm sure this can be done more elegantly but Lisp's string handling seems to be very werd. ...
user avatar
2 votes
3 answers
207 views

BST traverse as higher order function [closed]

Consider the following function to traverse a BST ...
user avatar
  • 483
2 votes
1 answer
96 views

Abstracting on Common Lisp Function Keyword Parameters

This is an experiment on extending a basic built-in Common Lisp sequence function (namely remove), in order to provide more functionality with little or no impact ...
user avatar
  • 405
3 votes
3 answers
95 views

Find minimum value in a BST: using boolean operators, and using conditionals

I've been studying the BST code in Paul Graham's ANSI Common Lisp. He provides (my comments): ...
user avatar
  • 483
2 votes
3 answers
1k views

Count frequencies of symbols in a list

I'd like to find a more elegant solution to the following. Below appears correct, but it's hard to read. Is my first use of the map function below poor in stylistic terms? It feels that way, and ...
user avatar
  • 483
1 vote
2 answers
98 views

Sum ints on stdin

I have been meaning to learn LISP and for a small task I wanted to find out the sum of all integers on STDIN. So for > clisp a.lisp 1 2 3^D 6 My code is as ...
user avatar
  • 620
0 votes
1 answer
32 views

Uncompressing a list with some run-length-encoded elements

Regarding the following code ...
user avatar
  • 483
5 votes
1 answer
79 views

Evaluator for adding and subtracting algebraic expressions

I wrote a little program that adds and subtracts some algebraic expressions. In my code (2 x 3) represents \$2x^3\$. The purpose of this post is to get some ...
user avatar
  • 51
2 votes
2 answers
127 views

Generating a list (or a string) with random elements

During implementation and testing of different small hobby projects I often reach the point where I need (at least I like it more) some random data beyond the usual foo-bar strings or lists. Random ...
user avatar
6 votes
1 answer
137 views

Calculating the cube root

Inspired by a question on SO I was checking how to calculate the cube root of an integer and found a C-ish solution on Hacker's Delight: ...
user avatar
2 votes
1 answer
400 views

merge function for mergesort - recursion vs. iteration

I decided to do an algorithms course (Roughgarden's on Coursera), and am setting out to implement each algorithm as it's introduced, in Lisp. We start with mergesort which is introduced as the ...
user avatar
  • 483
7 votes
1 answer
310 views

Binary Heap implementation in Common Lisp and tests

I implemented a basic binary heap in Common Lisp to learn programming using the CLOS. It is quite neat and self-contained, the core of the program is about 100 SLOC. The whole repository can be found ...
user avatar
3 votes
1 answer
52 views

Utmost function that takes a comparator function

I'm working through Paul Graham's "ANSI Common Lisp". In Chapter 6 (p105), he introduces the idea of utility functions. He points out these are core to bottom-up programming and reusability. He ...
user avatar
  • 483
1 vote
1 answer
807 views

Nested loop in lisp to process a 2d array - what's good style (with and/or without loop macro)? [closed]

Code below is answer to an exercise in Paul Graham's ANSI Common Lisp (ex. 4.1). The challenge is to rotate an array by 90 degrees. I found an example solution which I've commented below. It seems ok'...
user avatar
  • 483
1 vote
0 answers
63 views

Puzzling SBCL Compiler Note

I’m having trouble understanding an SBCL compiler note about unreachable code in the following function. The referenced code is attempting to push a value into an Lparallel queue: ...
user avatar
  • 405
5 votes
0 answers
142 views

A Parallel Processing Template for Divide & Conquer Problems

I’ve written a program for solving a problem using standard single-threaded code. However, it looks like it could be recast as a multi-threaded problem using divide & conquer. Since this is a ...
user avatar
  • 405
1 vote
1 answer
111 views

Enigma questions from "ANSI Common Lisp" [closed]

I'm working through Paul Graham's ANSI Common Lisp and in Exercise 2.5, I'm stumped. My specific question (I wasn't sure whether this type of question is suitable for stack overflow, code review, or ...
user avatar
  • 483
3 votes
2 answers
80 views

pos+ (value added to position) - ex 3.5 in “ANSI Common Lisp” (p57)

The problem is to take a list of integers and map them to another list containing those integers added to their respective position in the list. Example runs with required outputs: ...
user avatar
  • 483
6 votes
1 answer
501 views

Occurrences (frequency count) - exercise 3 ch. 3 in "ansi common lisp"

Looking for hints on style and clarity re. below. While I'm not saying speed is irrelevant, it's less of a priority than style & avoiding bad habits at this point. Focus is on clean use of ...
user avatar
  • 483
1 vote
1 answer
247 views

Verify that each named sequence is strictly increasing

The master launch sequence consists of several independent sequences for different systems. Your goal is to verify that all the individual system sequences are in strictly increasing order. In other ...
user avatar
  • 121
4 votes
1 answer
144 views

Implementing a tree parsing function

I've solved an assignment a week ago, which is my first assignment using Lisp. Tasks: Task 1: a. Given a tree as recursive lists, print the tree in breadth first order. b. Given a tree like ...
user avatar
3 votes
2 answers
480 views

A simple Tic Tac Toe game

I am trying to learn some Common Lisp, except basically all of my computing background is the C family of languages. So, I'm starting small. I have made a Tic-Tac-Toe game, and I am looking for some ...
user avatar
4 votes
1 answer
268 views

FizzBuzz in Common Lisp

Where I stand on Lisp So, Lisp. It's been on my radar for years and I'm finally getting around to learning it. The syntax is foreign but I find I'm having the most difficulty in the areas of ...
user avatar
2 votes
1 answer
129 views

Extracting XML data from a node in Common Lisp (Closure XML DOM)

This is a function intended to take an XML element (in closure XML format) and a name and find a piece of simple data by that name (either in a tag or attribute) within that XML element. It works, but ...
user avatar
6 votes
2 answers
803 views

Returning the prime factors of a number

I am trying to create a function prime-factors that returns the prime factors of a number. To do so, I created is-prime function,...
user avatar
  • 61
4 votes
0 answers
69 views

Pure functional code for the sublists of a list

The code below gives me the list of sublists of a list. Code can still be improved to avoid the use of append, right? ...
user avatar
4 votes
1 answer
165 views

lisp-koans Greed implementation

I have implemented Greed as part of the lisp-koans extra-credit challenge. I am seeking some general feedback with respect to Common Lisp style, appropriate use of language features, and so forth. ...
user avatar
  • 143
3 votes
2 answers
822 views

Reading lines of integers into a list of lists

I have a text file containing integers in different lines which I want to read into a list of lists. So 01 11 14 45 50 09 should become ...
user avatar
1 vote
1 answer
108 views

Calculating insulin bolus dose and infusion rate

I wrote a hobby program to ease the job of nurses to calculate insulin bolus dose and infusion rate according to measured blood glucose. There are several protocols around. Almost all hospitals ...
user avatar
  • 225
8 votes
1 answer
211 views

Scoring poker hands

Just for fun I solved another Project Euler problem dealing with poker cards. I think it is also part of other programming puzzles which can be found in the web. While there is not much mathematics in ...
user avatar
5 votes
2 answers
4k views

Split a list into two parts with a given length

I'm learning Common Lisp as a hobby and am trying tasks from L-99: Ninety-Nine Lisp Problems, but I'm not sure how good my code is. Here is one of the tasks which I solved: GitHub solution ...
user avatar
  • 153
2 votes
1 answer
301 views

Pairwise grouping of elements of a list

I want to group the elements in an arbitrary long list into pairs and implemented the following so far: ...
user avatar