Functional Programming

0 comments

In this project, we should use the original functional programming language: Lisp.

Functional programming is based on lambda calculus. Just like actually programming a Turing machine is quite involved, programming directly using the lambda calculus would be painful.

List Functions

1. Append two lists

2. Reverse a list

3. Map a function over every element in a list (this is called mapcar in Lisp)

4. Remove duplicates from a list

5. Fold-left

6. Filter

7. Merge two sorted lists

8. Add an element to the end of a list

9. Index of

10. Remove-all

Set Functions

1. Set membership

2. Insert element into set

3. Set intersection

4. Set union

5. Set difference

6. Symmetric difference

7. Check if subset or equal

8. Check if superset or equal

9. Cardinality

10. Power set

1. Absolute value

2. Factorial

3. Check if 3 integers can be the lengths of the two sides and the hypoteneuse of a right triangle (in that order)

4. Greatest Common Divisor (GCD) (gcd 8 12) => 4

5. Least Common Multiple (LCM) (lcm 4 6) => 12

6. Nth Fibonacci number

7. Test if a number is prime

8. Nth prime number

Required Functions

1. Generate the nth triangular number, which is the sum of the sum of the n natural numbers from 1 to n.

2. Test whether a given number is a triangular number. (trip 6) => t (trip 7) => nil

3. Test whether a given number is the sum of two triangular numbers. (tritri 14) => nil (tritri 18) => t

Read-Eval-Print Loop (REPL)

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}