I tried out Lisp for the first time. It’s a functional/declarative programming language which is so much more different from an imperative language like Java that I was totally confused at first. I wrote a few lines of simple code.
I think that this sort of coding would be useful for AIs that have to solve problems given certain values and constraints such as chess AIs or Tic Tac Toe AIs. However, AIs that actually “do” something should be programmed in declarative languages like Java and C++.
Code:
(defun add(A B)
(+ A B))
(defun subtract(A B)
(- A B))
(defun multiply(A B)
(* A B))
(defun factorial(N)
(if (or (= N 1) (= N 0))
1
(* N (factorial(- N 1)))))
(print(factorial 8))
(print(add 8 5))
(print(subtract 8 2))
(print(multiply 8 5))
Output:
40320 13 6 40
You should add “I am a Nigerian Prince” at the end of your program!
Go away or I’ll threaten you with Katie’s chicken.
Who’s katie?
A girl in Environmental Science who tried to force-feed David some chicken.