Stack Exchange Network

Stack Exchange network consists of 175 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 [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.

7
votes
0answers
67 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 ...
2
votes
1answer
31 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 ...
3
votes
2answers
95 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 ...
6
votes
0answers
59 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 ...
0
votes
0answers
55 views

SICP exercise 3.47 - implementing a semaphore in terms of mutexes

Can anyone check my solution to the first part of exercise 3.47 in SICP? Thanks. Exercise 3.47: A semaphore (of size n) is a generalization of a mutex. Like a mutex, a semaphore supports acquire ...
1
vote
1answer
480 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 ...
4
votes
1answer
112 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 ...
3
votes
2answers
168 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 ...
1
vote
0answers
32 views
4
votes
1answer
72 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
0answers
133 views

Prototype of an idle game (very early, but you can try it)

I am currently fiddling with ClojureScript and Reagent, and I'm trying my hands at an Idle game. I'm somewhat familiar with FP, and pretty new to Clojure/ClojureScript and Reagent/React. I'd like a ...
6
votes
2answers
179 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,...
2
votes
1answer
42 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 ...
4
votes
1answer
106 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. ...
0
votes
2answers
77 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 ...
5
votes
1answer
205 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 ...
3
votes
1answer
322 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 ...
3
votes
2answers
234 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 ...
4
votes
1answer
62 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 ...
4
votes
1answer
203 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 ...
4
votes
1answer
79 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 ...
0
votes
1answer
294 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 ...
1
vote
0answers
51 views

Point utilities in ClojureScript and Reagent

As one of my first "real" projects in Clojure(Script), I took one of the programming exercises from my Algebra II textbooks. The goal is to receive two 2D coordinates from the user and calculate the ...
1
vote
0answers
91 views

SICP - exercise 2.3 - Implement a representation for rectangles in a plane

Exercise 2.3. Implement a representation for rectangles in a plane. (Hint: You may want to make use of exercise 2.2.) In terms of your constructors and selectors, create procedures that compute the ...
3
votes
3answers
224 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,...
7
votes
1answer
84 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. ...
4
votes
2answers
68 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 ...
9
votes
2answers
252 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 ...
5
votes
2answers
415 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 ...
2
votes
0answers
102 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. ...
2
votes
1answer
160 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 ...
1
vote
2answers
740 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'...
1
vote
2answers
2k 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: ...
2
votes
2answers
121 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
0answers
110 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 ...
1
vote
2answers
2k 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
193 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 ...
3
votes
1answer
343 views

Church Numerals

Here is exercise 2.6 from SICP: Exercise 2.6: In case representing pairs as procedures wasn’t mind-boggling enough, consider that, in a language that can manipulate procedures, we can get by ...
3
votes
1answer
136 views

SICP exercise 1.28 - miller-rabin primality test part II

This is a follow-up to SICP exercise 1.28 - miller-rabin primality test. Exercise 1.28: One variant of the Fermat test that cannot be fooled is called the Miller-Rabin test (Miller 1976; ...
6
votes
1answer
87 views

PE4: Largest Palindrome Product (Clojure)

I solved Project Euler 4 using Clojure Lisp. A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest ...
13
votes
2answers
871 views

A Lisp version of the Schwartzian transform

Randal Schwartz stole Lisp's decorate-sort-undecorate idiom when he came up with what we'd later call the Schwartzian transform. All of my Lisp knowledge disappeared through nine half lives, but I ...
2
votes
1answer
66 views

Find common factor of numbers in a list

This program calculates common factor for given numbers. The original use case is to find a possible resolution for pixel games that scale well with new screen resolutions (that's why I don't have any ...
4
votes
3answers
147 views

Netstring parser in common lisp

Below is a netstring parser I wrote in Common Lisp. The docstring contains the usage and return. ...
1
vote
1answer
222 views

Exercism: clean and format a phone number in Clojure

Problem statement Phone Number Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is ...
2
votes
1answer
179 views

SICP exercise 1.28 - miller-rabin primality test

From SICP Exercise 1.28: One variant of the Fermat test that cannot be fooled is called the Miller-Rabin test (Miller 1976; Rabin 1980). This starts from an alternate form of Fermat’s ...
5
votes
1answer
97 views

Selecting HTML nodes

I'm new to Clojure, and I'm writing some code that processes HTML. I'm parsing the HTML using clj-tagsoup and then trying to pull out the relevant bits with this function: ...
3
votes
1answer
70 views

SICP 1.3 Sum of Squares of two largest numbers

Define a procedure that takes three numbers as arguments and returns the sum of squares of the two largest numbers. I'm using just the machinery that was developed so far in SICP to be true to the ...
1
vote
1answer
171 views

SICP - exercise 1.12 - pascal's triangle

From SICP: Exercise 1.12: The following pattern of numbers is called Pascal’s triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 . . . The numbers at the ...
4
votes
2answers
314 views

Tail recursive FizzBuzz in Common Lisp

I solved FizzBuzz using tail recursion. Is it efficient enough? ...
8
votes
1answer
509 views

“Curious Numbers” (HackerRank PE 34)

I was inspired by a certain recent question to try my hand at this challenge: Project Euler #34: Digit factorials \$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible by \$19\$...