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
4 answers
1k views

Finding the sum of all the multiples of 3 or 5 below 1000

As a Lisp (and functional programming) newbie, I wrote the following code that finds the sum of all the multiples of 3 or 5 below 1000, and I suspect that it is lousy: ...
henginy's user avatar
  • 183
8 votes
1 answer
882 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\$...
Phrancis's user avatar
  • 20.4k
8 votes
2 answers
297 views

Compiler for a minimal LISP dialect to run on the Java Virtual Machine

As the title states, this is a compiler written in C with a ruby build script that translates a minimal LISP dialect and spits out an executable jar file. I designed this LISP dialect and named it ...
user avatar
4 votes
2 answers
3k views

Print an integer and its digits reversed

This Common Lisp program is an exercise to print an integer and its digits reversed to the screen: ...
jaresty's user avatar
  • 2,243
4 votes
2 answers
542 views

Tail recursive FizzBuzz in Common Lisp

I solved FizzBuzz using tail recursion. Is it efficient enough? ...
min's user avatar
  • 43
3 votes
1 answer
1k views

Huffman encoding successive-merge function

From SICP: Exercise 2.69. The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and generates a Huffman encoding ...
jaresty's user avatar
  • 2,243
3 votes
2 answers
2k views

Use Newton's Method to compute sqrt(x)

Given the following task: Use Newton's method to compute the square root of a number. Newton's method involves successive approximation. You start with a guess, and then continue averaging ...
jaresty's user avatar
  • 2,243
3 votes
1 answer
222 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; ...
lightning_missile's user avatar
2 votes
1 answer
299 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 ...
lightning_missile's user avatar
2 votes
1 answer
85 views

Replacing elements from a list and its sublists

Write a procedure substitute that takes three arguments: a list, an old word, and a new word. It should return a copy of the list, but with every occurrence of the old word replaced by the new word, ...
lightning_missile's user avatar
2 votes
1 answer
328 views

Machine epsilon - find epsi

4.2 Machine Epsilon Find the floating point number epsi that has the the following properties: 1.0+epsi is greater than 1.0 and Let m b e any number less than epsi. Then 1.0+m is ...
jaresty's user avatar
  • 2,243
1 vote
1 answer
317 views

Defining a unique-pairs procedure

From the section called Nested Mappings Exercise 2.40 Define a procedure unique-pairs that, given an integer n, generates the sequence of pairs (...
jaresty's user avatar
  • 2,243