Skip to main content
8 votes

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

Use primitive functions and operators as much as possible You are defining remove-dups, and in this function you use the primitive ...
Renzo's user avatar
  • 2,095
7 votes

Count frequencies of symbols in a list

This is the typical situation where a hash table that maps elements to their frequency count is particularly well suited. ...
Renzo's user avatar
  • 2,095
6 votes

Returning the prime factors of a number

There are several problems with your code. Style is-prime is C/Java style. Lispers use primep or ...
sds's user avatar
  • 1,425
6 votes

FizzBuzz in Common Lisp

1. Divisible function It is perfectly fine to define a function like divisible to improve the reading of a program. In general, ...
Renzo's user avatar
  • 2,095
6 votes
Accepted

lisp-koans Greed implementation

Don't take all remarks as absolute. Some are just how I would do things. There are many ways to structure a program. It's a great way to learn Lisp programming! Good: documented constant values with ...
Rainer Joswig's user avatar
6 votes

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

The aspect of the code that may cause difficulty to those new to Lisp appears to be the fact that in Common Lisp, nil has two meanings. It's the value of an empty ...
Edward's user avatar
  • 67.2k
6 votes
Accepted

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

You are asking: which version would you favour and why? Instead of answering directly to your question, I will try to show why that formulation is not, at least in my opinion, “a relic of former ...
Renzo's user avatar
  • 2,095
6 votes

Simple JSON parser in lisp

specification Please mention the URL of a JSON spec. near the top of this codebase. Extra points for mentioning the URL of some corpus of known-good and known-bad inputs you have tested against. EOF ...
J_H's user avatar
  • 42.3k
6 votes

Simple JSON parser in lisp

(defun mk-scanner (s) (list :stream s :cursor 0)) Using a property list for your scanner type is pretty unusual. Normally in Common Lisp you'd use a structure or ...
Shawn's user avatar
  • 431
5 votes

merge function for mergesort - recursion vs. iteration

There are some cases to be considered. Though we can write it slightly different: ...
Rainer Joswig's user avatar
5 votes

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

For loop you can see the excellent book by P. Seibel “Practical Common Lisp”, available on-line, in particular chapter 7 and chapter 22. Let’s start from the last ...
Renzo's user avatar
  • 2,095
5 votes
Accepted

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

Conditions In general something like "if a then true else false" can be simplified as "a". So your first function could be simplified as: ...
Renzo's user avatar
  • 2,095
5 votes
Accepted

count pairs of matching integers in a collection in Common Lisp

Stylistic consideration: a global variable is usually written with double "*" (earmuffs), so the global variable integers should be written as ...
Renzo's user avatar
  • 2,095
4 votes
Accepted

Reading lines of integers into a list of lists

A simple possibility could be to enclose each row between parentheses and use read-from-string (assuming that the file does not contain incorrect data): ...
Renzo's user avatar
  • 2,095
4 votes
Accepted

Implementing a tree parsing function

A few considerations about the style of the code. Generalized booleans In Common Lisp the only value “false” is NIL, every other value is considered “true”. So, ...
Renzo's user avatar
  • 2,095
4 votes
Accepted

A simple Tic Tac Toe game

Here are a few considerations. DEFPARAMETER vs. DEFVAR The first three definitions should be given with defparameter instead of ...
Renzo's user avatar
  • 2,095
4 votes

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

General style remarks lst is more of a Scheme idiom, in Common Lisp you don't eat vowels but write directly list if your ...
coredump's user avatar
  • 913
4 votes
Accepted

BST traverse as higher order function

Is this higher order function any use at all without relying on a side-effect? The answer to this question is obviously no, since the function returns always nil. ...
Renzo's user avatar
  • 2,095
4 votes
Accepted

Lispy code? Prime factors of a number

Your code is perfectly fine, except for a few nitpicks. Use push instead of (setf x (conx y x)) for readability. Use ...
sds's user avatar
  • 1,425
4 votes
Accepted

Deque class in Common Lisp

little review based on this style guide: https://lisp-lang.org/style-guide/, itself much based on Google's. the slots order should be accessor, initarg, initform, type. use the :type slot. They are ...
Ehvince's user avatar
  • 156
4 votes
Accepted

Count complete trips to the basement and back to ground floor

A few points. if with only the “then” case is usually written with when, which is in general more handy since it allows several ...
Renzo's user avatar
  • 2,095
4 votes
Accepted

Lexically-scoped Lisp interpreter

Interesting project. Being "similar" to a big system like Common Lisp introduces a pretty giant documentation burden. Consider starting with R7RS-small, and then describing the deltas. ...
J_H's user avatar
  • 42.3k
4 votes

Advent of Code 2015 "Not Quite Lisp", in Common Lisp

I'd write this in Common Lisp as something like ...
Shawn's user avatar
  • 431
3 votes
Accepted

Calculating the cube root

There is not much to say about this code, it is fine. You can get rid of incf and setf; the varying ...
coredump's user avatar
  • 913
3 votes
Accepted

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

A few comments about your code: Why introduce a new variable n copy of another variable? If you want to be more concise you could use ...
Renzo's user avatar
  • 2,095
3 votes
Accepted

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

you can use REMOVE instead of the LOOP you can replace the CONDs and IFs and ERRORs with ASSERT replace CAR with FIRST The specific functions make the intent of the code a bit more clear. Untested: <...
Rainer Joswig's user avatar
3 votes
Accepted

Pairwise grouping of elements of a list

Much too complicated. Use MAPCAR: ...
Rainer Joswig's user avatar
3 votes
Accepted

Scoring poker hands

Some remarks: &aux variables can reduce the indentation level. Here we can also get rid of the with & ...
Rainer Joswig's user avatar
3 votes
Accepted

Split a list into two parts with a given length

Let’s use a completely different approach: first try to solve the problem using predefined (complex) functions, then implement those functions with the primitive ones (recursion, car, cdr, etc.) So, ...
Renzo's user avatar
  • 2,095
3 votes

Insertion sort in Common Lisp

You were trying to implement the algorithm as it is described for collections with certain properties, which, as noted by sds led you to create a very inefficient implementation, since the property ...
wvxvw's user avatar
  • 1,001

Only top scored, non community-wiki answers of a minimum length are eligible