Little fun things to do in CL
Little fun things to do in CL
Hi guys
I'm looking for little things that I can do with CL. I've been trying to learn the language for quite some time. I am finding it hard to get a grip on the language. So I would like a list(pun) of fun things to do in the language. Like changing the text color and mini text based games. I have a copy of Land of Lisp with no luck of understanding the language to well. Maybe I shouldn't have started out with C++ a few years back. I want CL for the power nothing more.
I'm looking for little things that I can do with CL. I've been trying to learn the language for quite some time. I am finding it hard to get a grip on the language. So I would like a list(pun) of fun things to do in the language. Like changing the text color and mini text based games. I have a copy of Land of Lisp with no luck of understanding the language to well. Maybe I shouldn't have started out with C++ a few years back. I want CL for the power nothing more.
Re: Little fun things to do in CL
Hi voosey,
I see that nobody has answered your question so far, so here some chatter from the ##lisp IRC channel on Freenode.net with funny Lisp code.
Everything started with the question "if woah is a misspelling of whoa, what is the meaning of woah?" Then I looked at urbandictionary.com and there was written "Woah, you have nothing better to do with your time than to look up the spelling of woah." Some other guy said: "Woah, that's a recursive definition of woah!" and that's why I wrote this recursive definition of woah:
(princ "WOAH! ") prints WOAH! and a space character without any line-break, then the function calls itself until (random 10) returns a zero. (finish-output) flushes the output buffer.
Here's what happens at the REPL:
Then we saw that WOAH! looks like batman fight noise what lead to the following code:
(nth (random (length words)) words) picks a random word from the list of words. (format t <format-string> <arguments>) prints the arguments as a string to the *standard-output* stream. (remove word words) removes the printed word from the list of words before the function is recursively called to avoid duplicate words on the screen.
Here you can watch batman fight at the REPL:
In the CLiki (Common Lisp Wiki) under Getting Started there are lots of links to free books and other stuff.
- edgar
I see that nobody has answered your question so far, so here some chatter from the ##lisp IRC channel on Freenode.net with funny Lisp code.
Everything started with the question "if woah is a misspelling of whoa, what is the meaning of woah?" Then I looked at urbandictionary.com and there was written "Woah, you have nothing better to do with your time than to look up the spelling of woah." Some other guy said: "Woah, that's a recursive definition of woah!" and that's why I wrote this recursive definition of woah:
Code: Select all
(defun woah ()
"Print some nonsense recursively a random number of times."
(princ "WOAH! ")
(if (zerop (random 10))
(finish-output)
(woah)))
Here's what happens at the REPL:
Code: Select all
CL-USER> (woah)
WOAH! WOAH! WOAH! WOAH! WOAH! WOAH! WOAH! WOAH!
Code: Select all
(defparameter *noise* '(awk bam bang biff blop boff bonk clank clash clunk
crash crunch kapow klonk klunk krunch pam plop pow slosh splat swap swish
swooch thunk twack ugh urk vronk whack wham whap zam zap zlonk zlop zlot
zok zow zwap)
"Weird batman fight noise.")
(defun batman (words)
"Make some batman fight noise of random words and length."
(let ((word (nth (random (length words)) words)))
(cond ((zerop (random 10))
(format t "~S!~%" word)
(finish-output))
(t
(format t "~S!, " word)
(batman (remove word words))))))
Here you can watch batman fight at the REPL:
Code: Select all
CL-USER> (batman *noise*)
SWOOCH!, URK!, CRUNCH!, ZOK!, ZAP!, PLOP!, UGH!, PAM!
- edgar
Re: Little fun things to do in CL
Wow, that is pretty cool. I remember learning other languages and having fun during the process sure helps. I wounder what else can be done, for new comers like myself?
-
- Posts: 166
- Joined: Sun Nov 28, 2010 4:21 pm
Re: Little fun things to do in CL
It's hard to know what to suggest here, CL can do almost anything you can think of, so it really needs to be something that YOU are interested in.
To give you some examples of itches that I've scratched with CL:
That doesn't mean interesting things can't been done with native apps, sketch (not mine) looks quite cool.
To give you some examples of itches that I've scratched with CL:
- A tool for creating project skeletons and managing them with source control for easy use across my computers (including symlinking .asd files in my system directory, blast from the past!)
- A solver for Picross/nonograms
- A script that stitches together webpages into a single document
- A small webapp that serves files from a .zip file (saving my laptop's SSD from the java documentation's MASSIVE number of tiny files, when I'm away from wi-fi)
- A code-sharing web-app that allows interactive macroexpansion (source) (demo)
- A proxy for an amateur fiction site that let's me easily track spelling and grammar mistakes to submit to the author once I'm finished
- And my music streaming web-app that I've been growing features on, whenever something starts to bug me too much
That doesn't mean interesting things can't been done with native apps, sketch (not mine) looks quite cool.
Re: Little fun things to do in CL
I once wrote this code when I was introducing myself to multithreading in Common Lisp. It prints colored text into the console, it uses ANSI escape sequences (on Windows I recommend start using ansicon; don't miss the release page), the other possibility is to use one of the bindings to the ncurses/PDCurses library.voosey wrote:Like changing the text color and mini text based games.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
-
- Posts: 1
- Joined: Mon Jul 11, 2016 2:45 pm
Re: Little fun things to do in CL
I've been going through the Winston/Horn book to re-acquaint myself with lisp.
I think for many (me included), it's nice to get visual responses to things when learning languages. Plotting lines or drawing with ascii for example.
If you can draw lines with your installation of Common Lisp, on page 76 of Winston/Horn there's a recursive function that draws 'c curves'.
You also need
You would need to define your own 'draw-line' that draws into a target window. x-old and y-old are global.
I can post the 'dragon-curve', once I have worked it out.
I think for many (me included), it's nice to get visual responses to things when learning languages. Plotting lines or drawing with ascii for example.
If you can draw lines with your installation of Common Lisp, on page 76 of Winston/Horn there's a recursive function that draws 'c curves'.
Code: Select all
(defun c-curve (length angle min-length)
(cond ((< length min-length) (plot-line length angle))
(t (c-curve (/ length (sqrt 2.0))
(+ angle (/ pi 4.0))
min-length)
(c-curve (/ length (sqrt 2.0))
(- angle (/ pi 4.0))
min-length))))
Code: Select all
(defun plot-line (length angle)
(connect-line (+ x-old (* length (cos angle)))
(+ y-old (* length (sin angle)))))
(defun connect-line (x-new y-new)
(draw-line x-old y-old x-new y-new)
(setq x-old x-new y-old y-new))
I can post the 'dragon-curve', once I have worked it out.
Lisp novice.