Skip to main content

Questions tagged [lisp]

Lisp is a (family of) general purpose programming language(s), based on the lambda calculus, and with the ability to manipulate source code as a data structure.

Filter by
Sorted by
Tagged with
7 votes
2 answers
330 views

Lexically-scoped Lisp interpreter

Introduction Here's an interpreter, written in Common Lisp, for a simple Lisp dialect that has some semi-“advanced” features, namely lexical scope with closures, ...
texdr.aft's user avatar
  • 258
8 votes
1 answer
121 views

Lisp-like language interpreter in Python

I decided to learn more about how interpreters work and made a simple Scheme interpreter in Python. I'd like to hear some advice on how I could have written this better, or on the mistakes I've made. ...
guy25678's user avatar
3 votes
0 answers
106 views

Destructive quick and merge sort

I've implemented a destructive merge and quick sort in common lisp, but the code feels verbose and highly imperative. I was wondering if anyone could offer guidance on idioms that could make the code ...
bfair's user avatar
  • 131
0 votes
2 answers
287 views

Split a list into two parts

I wanted to split a list into 2 parts, as per the chosen size, first the size and then the list. Example: (split 3'(1 3 5 7 9)) ...
The Nightm4re's user avatar
3 votes
0 answers
260 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 ...
rose's user avatar
  • 325
1 vote
1 answer
45 views

Installing packages when needed

I decided to create a portable Emacs config and install packages I use if it's necessary on a fresh computer. Here is what I've done: ...
user4035's user avatar
  • 293
5 votes
0 answers
96 views

Hide your text with colorful blocks in secret(-mode)

Motivation While working on a completely unrelated task, I wanted to share a screenshot of my current Emacs frame, but not of the actual text contents. And while GIMP's pixelate filter did the job, I ...
Zeta's user avatar
  • 19.3k
1 vote
0 answers
112 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
416 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
0 answers
65 views

Emacs lisp advice to start ipython repl in the project root

When starting an ipython repl for my project at work, I pretty much always want it started in the project root, not adjacent to the file for the buffer I'm viewing (this is python and module loading ...
George Mauer's user avatar
  • 1,652
4 votes
1 answer
57 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. ...
user235906's user avatar
3 votes
0 answers
184 views

LOVE2D-based grid-movement rhythm game in Fennel

This is the initial skeleton for a short game written in Fennel for a Jam event. It runs sensibly, but I want to know if I'm missing something that could make the code more elegant as it's a bit ...
Mark Green's user avatar
6 votes
1 answer
102 views

WOMOIWIW: What Org-mode Opens is What I Want

Motivation Previously, on the Emacs stack exchange: In Org mode, when I open a link (C-c C-o) [...] [that] contains a wildcard, such as file:3_o*.pdf, Emacs opens ...
Zeta's user avatar
  • 19.3k
2 votes
0 answers
37 views

define a lisp function, that takes fsm , a transition and state-index and return the state obtained by the transition from the state

The state machine has the below specifications (defparameter *test-machine* (make-fsm :alphabet '(a b) :table '((2 1) (0 2) (1 0)) :initial 0 :accepting '(2))) ...
Ssunsshine's user avatar
3 votes
1 answer
332 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, ...
Paulo Mendes's user avatar
2 votes
0 answers
50 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 ...
pmg's user avatar
  • 520
3 votes
2 answers
250 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", ... ...
pmg's user avatar
  • 520
3 votes
1 answer
268 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 ...
pmg's user avatar
  • 520
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
4 votes
1 answer
154 views

My implementation of Clojure's assoc-in

This is my implementation of Clojure's assoc-in function. I am looking for tips on making it more idiomatic and in general, better. ...
Navarro's user avatar
  • 165
13 votes
1 answer
423 views

(Lisp in (Rust))

I loved Norvig's Lispy, and made the first version of it in Rust, to learn Rust. I would love your thoughts :) A few specific questions: Is there a way to write ...
Stepan Parunashvili's user avatar
3 votes
2 answers
97 views

Check for pangrams in elisp

I'm trying to find pangrams ie sentences that contain all the letters of the alphabet, for instance "The quick brown fox jumps over the lazy dog". I'm an absolute beginner in elisp, and it ended up ...
little-dude's user avatar
5 votes
2 answers
789 views

Parsing infix expressions in Clojure

I'm trying to teach myself Clojure by reading the Brave Clojure book online, and at the end of Chapter 7 there is an exercise to parse a mathematical expression written as a list in infix notation to ...
Eric Zhang's user avatar
9 votes
1 answer
119 views

Edis: Emacs driven indentation script

Motivation I recently picked up Emacs. As part of the process, I've started to configure the editor to fit my needs with Emacs Lisp. The Elisp indentation rules are still foreign to me, so I pretty ...
Zeta's user avatar
  • 19.3k
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
149 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 ...
Mikhail Krassavin's user avatar
3 votes
2 answers
553 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 ...
user1762507'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
6 votes
2 answers
956 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,...
Benz's user avatar
  • 61
2 votes
1 answer
52 views

Storing facts for logical questions

I am writing a crude artificial intelligence program. I am happy with my program's ability to file away new word in ways that will allow logic to be done on them. Before I start expanding the logic ...
Gregg Arthur Evans's user avatar
4 votes
1 answer
184 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. ...
dtg's user avatar
  • 143
0 votes
2 answers
226 views

Generate list of shape in Lisp

I quickly created this function in Lisp that resembles numpy.random.randint(low, high=None, size=None, dtype='I') The goal is simply to have a function that ...
JNevens's user avatar
  • 227
5 votes
1 answer
524 views

Axiomatic Lisp interpreter in C

This is not obfuscated. Or at least, that's not the intent. Let me try to address that concern straightaway. The goal here is brevity in the vein of Strunk&White. Nor is this codegolf, although ...
luser droog's user avatar
  • 2,038
3 votes
1 answer
784 views

Lisp Interpreter written in JavaScript

I had a task to reduce my Lisp Interpreter from 400 lines to 120 lines. I was able to bring it down to 255 lines without including newline after every function. I'm not able to figure out where I can ...
Akshay Iyer's user avatar
3 votes
2 answers
756 views

SICP - exercise 1.7 better end test for square root approximation

Here is exercise 1.7 from SICP: Exercise 1.7 The good-enough? test used in computing square roots will not be very effective for finding the square roots ...
lightning_missile's user avatar
4 votes
1 answer
75 views

Generating lists of sequences of specified lengths

I'm writing a program that uses a Genetic Algorithm to "intelligently brute force" our schedule at work. We typically have issues with creating schedules, so I thought using my new GA library to ...
Carcigenicate's user avatar
4 votes
1 answer
334 views

(SBCL) ASCII Game of Life

I'm implementing Conway's Game of Life in Lisp to familiarize myself with the language, with the eventual goal of hosting it on a website with a pretty GUI. I'm a hobbyist and inexperienced (this is ...
plishplop's user avatar
4 votes
1 answer
119 views

Minimal substring with all characters contained in string

I was given following task in the interview: Given a string, find shortest substring in it that contains all of the different characters contained in the original string. Here is my solution in ...
Srv19's user avatar
  • 455
0 votes
1 answer
401 views

Reinforcement learning example (chap. 1) from Sutton's book

I ported the Lisp Tic Tac Toe code from Chapter 1. to Haskell. The original code repo is down for some reason. I believe I have completely rewritten that in Haskell (Less functional than one would ...
Mohan Radhakrishnan's user avatar
3 votes
3 answers
492 views

Invert the bits of a non-negative integer in Common Lisp (SBCL)

I'm doing code challenges to learn Common Lisp. I'm trying to invert all the bits in any given positive integer. My current solution does it the math way, by recursing on a number, dividing it by two,...
Gustav Bertram's user avatar
8 votes
1 answer
104 views

A heart.lisp I wrote with my 6 year old daughter

Is it possible to improve this program somehow? It will probably be more convenient to suggest edits as forks of this Gist. ...
Alexander Artemenko's user avatar
4 votes
2 answers
83 views

Definition of power functions

I needed to write a simple function that could raise a value x to the n'th power. I found out I could write this function in 2 ...
JNevens's user avatar
  • 227
10 votes
2 answers
389 views

Project Euler #2 (classic) - Sum of even fibonacci numbers below 4 million

I'm looking to use LISP as best I can, not just get the right answer. This is very early on in my LISP career so feedback is welcome and exciting! Recently asked about Project Euler #1, got some ...
tscizzle's user avatar
  • 277
5 votes
2 answers
438 views

Sum of all multiples of 3 or 5 below 1000 (Project Euler #1 - typical)

I'm learning LISP and am starting with Project Euler. I would love some initial feedback on my LISP code for this simple task. I know it spits out the correct answer, but what I'm not sure about is ...
tscizzle's user avatar
  • 277
2 votes
0 answers
151 views

Computing nth roots of a number - SICP exercise 1.45

From SICP Exercise 1.45: We saw in 1.3.3 that attempting to compute square roots by naively finding a fixed point of x/y does not converge, and that this can be fixed by average damping. ...
lightning_missile's user avatar
2 votes
1 answer
507 views

Approximating pi/4 using Wallis Product - SICP exercise 1.31

From SICP The sum procedure is only the simplest of a vast number of similar abstractions that can be captured as higher-order procedures. Write an analagous procedure called product that ...
lightning_missile's user avatar
1 vote
2 answers
2k views

Pascal's triangle in mit-scheme

As suggested by the name of source file (ex1.12.scm), I just started learning mit-scheme by reading SICP. In Exercise 1.12, I'm asked to "compute elements of Pascal'...
nalzok's user avatar
  • 513
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
2 votes
2 answers
203 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
0 answers
328 views

Converting a sentence string to a number in Scheme

I wrote a scheme procedure that converts strings such as "Two hundred and fifty" into a number like "250" that I can use in math calculations (It's for some Natural Language Processing project). Is ...
Dawit Abraham's user avatar