Silly/fun/cool Lisp code snippets!!

Started by
445 comments, last by Tron3k 19 years, 3 months ago
Lisp is such a crazy language and it's so concise that you can do fun stuff in only a few lines. Post some Lisp!!

;; Wouldn't it be cool if GameDev had a Lisp interpreter?
(defun in-soviet-russia (noun verb)
    (concatenate 'string "In Soviet Russia, " noun "s " verb "YOU!"))

;; Calculate any factorial (even 43044!) AT COMPILE TIME!!
(defmacro fac (n)
    (do ((i 1 (1+ i))
         (x 1))
        ((> i n) x)
        (setf x (* x i))))

;; So then you just need to do...
(proclaim '(optimize speed))
(defun my-huge-number () (fac 43044))
(compile 'my-huge-number)

Ok guys, go crazy...
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Advertisement
I'm not quite thure I underthand what you're on about thur.
It'th not nithe to make fun of people with thpeetth impedimenth!

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Quote:Original post by benryves
I'm not quite thure I underthand what you're on about thur.
It'th not nithe to make fun of people with speeth impedimenth!
I believe that joke dates back to ancient Egyptian times. [wink]
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Quote:Original post by benryves
I'm not quite thure I underthand what you're on about thur.
It'th not nithe to make fun of people with speeth impedimenth!
*ahem*

thpeetth.
Quote:Original post by C-Junkie
Quote:Original post by benryves
I'm not quite thure I underthand what you're on about thur.
It'th not nithe to make fun of people with speeth impedimenth!
*ahem*

thpeetth.


It'th late [sad]

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

(let ((a car))(setq car cdr cdr a))
Possible Lisp Workflow...
  • Know your domain

  • Write a program using an optimal but not yet in existence mini-language that works effectively in your domain

  • Use Lisp defmacros to massage your mini-language into actual Lisp statements
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
(defun gheyify (str)    (let ((result ""))         (dotimes (i (length str) result)              (setf result (concatenate 'string                                        result                                        "<font color=\""                                        (if (= 0 (mod i 2)) "red" "green")                                        "\">"                                        (string (char str i))                                         "</font>")))))


that's pretty gay, don't you think?
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
What happened to the n? edit: huh. nm fixed.
Quote:Original post by C-Junkie
What happened to the n? edit: huh. nm fixed.
Sorry, I copy and pasted wrong.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson

This topic is closed to new replies.

Advertisement