Lisp links thread
Re: Lisp links thread
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
Re: Lisp links thread
thanks Simon
here's one about writing a scheme interpreter in python:
http://norvig.com/lispy.html
+ part 2:
http://norvig.com/lispy2.html
here's one about writing a scheme interpreter in python:
http://norvig.com/lispy.html
+ part 2:
http://norvig.com/lispy2.html
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: Lisp links thread
AAAAAAAAAAAARGH SCHEME AAAAAAAAAAAAAAAAAAARHG SCHEME AAAAAAAAAAAAAARGH LISP!
( .. sorry had to do that ) ..
I tried a few time the approach "and now I AM going to understand something about all this !".
But when I arrived at the chapter about "Lambda functions" something begins on the lines of "wtf ? what the hell are
they trying to say in there ?" ..
One of the things I never understood "clearly enough" is for example "what is LISP/Scheme suited for ?" ..
( .. sorry had to do that ) ..
I tried a few time the approach "and now I AM going to understand something about all this !".
But when I arrived at the chapter about "Lambda functions" something begins on the lines of "wtf ? what the hell are
they trying to say in there ?" ..
One of the things I never understood "clearly enough" is for example "what is LISP/Scheme suited for ?" ..
Giles the billy goat
"Baa"
"Baa"
- teamonkey
- Sheepie Whore

- Posts: 12082
- Joined: Thu Jun 13, 2002 1:07 am 0
- XBL Gamertag: itsthetaste
- PSN: teamonkey_ca
- Contact:
Re: Lisp links thread
Lambda is a function that creates an anonymous function.
This is a function that takes a parameter x and returns x+1.
It has no name but you can immediately call it.
Or assign it
Or pass it in to other functions that take a function
This is a function that takes a parameter x and returns x+1.
Code: Select all
(lambda (x)
(+ x 1))
Code: Select all
((lambda (x)
(+ x 1))
5)
; returns 6
Code: Select all
(define add-one
(lambda (x) (+ x 1)))
(add-one 2)
; returns 3
Code: Select all
(map
(lambda (x) (+ x 1))
'(1 2 3 4 5))
; returns '(2 3 4 5 6)
Re: Lisp links thread
Everything.gilesgoat wrote:One of the things I never understood "clearly enough" is for example "what is LISP/Scheme suited for ?" ..
Well, that's a bit of a push, but it's turing-complete so you can use it for anything you can use any other turing-complete language to do. Including writing games.
I was struck by a somewhat perverse notion whilst in that dreamy half-awake state this morning. Write a lisp interpreter in postscript.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
Re: Lisp links thread
Seems I'm not the only pervert. And the code looks almost as terrifying as I imagined it.tufty wrote:I was struck by a somewhat perverse notion whilst in that dreamy half-awake state this morning. Write a lisp interpreter in postscript.
http://interglacial.com/skreeth/
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: Lisp links thread
Can you give me some example of "something useful done" in LISP ?
Has anyone ever wrote an .ASM in LISP *hint* *hint*.
Now the only thing I would be VERY interested to see/know "how the hell they done it ?" is that I do know that
the whole NUON chip "emulation" while the chip was still into its developement stage was entierely wrote in Scheme and Yak
told me they were running stuff in this "emulator" that was slow as fuck but was simulating 100% the chip.
Now that is what I call "something".
Really jokes apart I never seen any "commercial appl" or such or <whatever> done in LISP, I always heard that
"LISP is very good to test stuff quick" but I mean I don't know .. certainly is "very different" from any other language
a coder ( of a certain 'school' ) is normally used to see.
What "scares" me ( really ) is that it seems to be "all based on recursion" while "HW minded people" are more "loop based".
Another thing that "scares" me is that "is so abstract" that ( to me at least ) "it's not very clear what I am working with"
I mean "what the heck I am passing to that function ?" .. is it an int ? is it something ? is it ANOTHER FUNCTION that
maybe is a function of a function of a function of another function of a thing ..
AAAAAAAAAAAAAAAARGH
The mind ( of the person that still sees the CPU as a CPU and the MEM as a 'linear set of things attached to and address bus" ) explodes ..
When I see a thing like :
Pappine ( 3, Pappine (2, 1) )
I think I am already "head on the desk" or such ..
Well ok maybe that's even "too simple too clear" but you get the idea.
Maybe more along the lines of :
Pappine (n) = n < 0 ? 0 : Pappine (n-1)
Here I start screaming.
They should make a book "LISP for those that can't get LISP" but I never seen one.
Has anyone ever wrote an .ASM in LISP *hint* *hint*.
Now the only thing I would be VERY interested to see/know "how the hell they done it ?" is that I do know that
the whole NUON chip "emulation" while the chip was still into its developement stage was entierely wrote in Scheme and Yak
told me they were running stuff in this "emulator" that was slow as fuck but was simulating 100% the chip.
Now that is what I call "something".
Really jokes apart I never seen any "commercial appl" or such or <whatever> done in LISP, I always heard that
"LISP is very good to test stuff quick" but I mean I don't know .. certainly is "very different" from any other language
a coder ( of a certain 'school' ) is normally used to see.
What "scares" me ( really ) is that it seems to be "all based on recursion" while "HW minded people" are more "loop based".
Another thing that "scares" me is that "is so abstract" that ( to me at least ) "it's not very clear what I am working with"
I mean "what the heck I am passing to that function ?" .. is it an int ? is it something ? is it ANOTHER FUNCTION that
maybe is a function of a function of a function of another function of a thing ..
AAAAAAAAAAAAAAAARGH
The mind ( of the person that still sees the CPU as a CPU and the MEM as a 'linear set of things attached to and address bus" ) explodes ..
When I see a thing like :
Pappine ( 3, Pappine (2, 1) )
I think I am already "head on the desk" or such ..
Well ok maybe that's even "too simple too clear" but you get the idea.
Maybe more along the lines of :
Pappine (n) = n < 0 ? 0 : Pappine (n-1)
Here I start screaming.
They should make a book "LISP for those that can't get LISP" but I never seen one.
Giles the billy goat
"Baa"
"Baa"
Re: Lisp links thread
http://paulgraham.com/booklinks.html some book links... the little schemer series is one i've heard good things about
- teamonkey
- Sheepie Whore

- Posts: 12082
- Joined: Thu Jun 13, 2002 1:07 am 0
- XBL Gamertag: itsthetaste
- PSN: teamonkey_ca
- Contact:
Re: Lisp links thread
Recursion is handled by compiler magic, Giles.
Not all lisp compilers can handle this, but a smart one will look at this code
And turn it into something like this (for example):
Because lisp code is basically just a big tree structure it's much easier for a compiler to work this stuff out than for C. There are other techniques too.
The other thing is tail call optimisation (TCO), so in code like this:
The compiler can see that there are two ways out of this function and realise that it can just branch out of my-func and straight into Pappine. Again, this is made simple because of the way lisp is structured.
This wouldn't be optimised though (unless your compiler was really smart) because it needs to do something to the value after Pappine returns:
Not all lisp compilers can handle this, but a smart one will look at this code
Code: Select all
(Pappine 3 (Pappine 2 1))Code: Select all
_temp_ = Pappine(2, 1)
return Pappine(3, _temp_)The other thing is tail call optimisation (TCO), so in code like this:
Code: Select all
(define (my-func n)
(if (eq? 0 n) ; if(n==0)
(Pappine 2 1) ; then return Pappine(2,1)
(Pappine 2 n))) ; else return Pappine(2,n)This wouldn't be optimised though (unless your compiler was really smart) because it needs to do something to the value after Pappine returns:
Code: Select all
(define (my-func2 n)
(+ 1 (if (eq? 0 n)
(Pappine 2 1)
(Pappine 2 n))))Re: Lisp links thread
gilesgoat wrote:Can you give me some example of "something useful done" in LISP ?
Has anyone ever wrote an .ASM in LISP *hint* *hint*.
A lot of this is written in a version of LISP. If you'd ever done PS2 work you'd know what a pain in the arse it is getting a game as tidy as this running at 60hz.
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: Lisp links thread
@Teamonkey
Ok I don't know if I should ask this but "let me try to understand" for example in this way.
"LISP" .. "Lists Processor" or such .. ok ..
Suppose, because I really would love to understand/see "how clever is LISP" and in theory I'd say "this is the kind of
stuff LISP should be done for" .. suppose I ask you to write a LISP program that does this :
1. Given a string of ASCII chars
2. Given a list, a set of strings of ascii chars, let's say N strings present (i.e. like ( "Apple","Cherry","Banana","Nut" ) )
The problem : "return a list of tokens in range 0 .. N-1 or '-1' if not found in the tokens list ".
This means :
1. Parse the string doing a "word count" skipping white spaces and such.
2. For each for check if the word is present in "List" and if so get the corresponding index
3. Output an "array" ? ( list ? ) with the numbers you found
Now to write this thing in C - let's assume PURE C and NOTHING ELSE ( i.e. no "funky libs" ) that could be made
in various ways, depens if that list of tokens also is big or "reasonably small" , I don't even mention C++ becuase
one could probably use STL or some other "strange classes" or such that maybe could even do that in 2 lines of code ..
Let's talk about "pure language".
Now in C you could do that "in a few ways" , I would probably do it with a "standard" "word search" pattern followed
by a search in that list any time a word is found before to proceed to the next, can probably do it single pass for sure.
Let's forget "how big that list could be", if it's a sorted list or not, if it's going to change "let's keep it simple".
But I'd love to see "how you solve a task like that using LISP" to understand "how well LISP goes for kind of problems like those".
IMHO I'd expect some sort of "super elegant solution" even if probably "not very optimized".
Ok I don't know if I should ask this but "let me try to understand" for example in this way.
"LISP" .. "Lists Processor" or such .. ok ..
Suppose, because I really would love to understand/see "how clever is LISP" and in theory I'd say "this is the kind of
stuff LISP should be done for" .. suppose I ask you to write a LISP program that does this :
1. Given a string of ASCII chars
2. Given a list, a set of strings of ascii chars, let's say N strings present (i.e. like ( "Apple","Cherry","Banana","Nut" ) )
The problem : "return a list of tokens in range 0 .. N-1 or '-1' if not found in the tokens list ".
This means :
1. Parse the string doing a "word count" skipping white spaces and such.
2. For each for check if the word is present in "List" and if so get the corresponding index
3. Output an "array" ? ( list ? ) with the numbers you found
Now to write this thing in C - let's assume PURE C and NOTHING ELSE ( i.e. no "funky libs" ) that could be made
in various ways, depens if that list of tokens also is big or "reasonably small" , I don't even mention C++ becuase
one could probably use STL or some other "strange classes" or such that maybe could even do that in 2 lines of code ..
Let's talk about "pure language".
Now in C you could do that "in a few ways" , I would probably do it with a "standard" "word search" pattern followed
by a search in that list any time a word is found before to proceed to the next, can probably do it single pass for sure.
Let's forget "how big that list could be", if it's a sorted list or not, if it's going to change "let's keep it simple".
But I'd love to see "how you solve a task like that using LISP" to understand "how well LISP goes for kind of problems like those".
IMHO I'd expect some sort of "super elegant solution" even if probably "not very optimized".
Giles the billy goat
"Baa"
"Baa"
Re: Lisp links thread
Yes.gilesgoat wrote:Has anyone ever wrote an .ASM in LISP *hint* *hint*.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"

