Lisp links thread

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
Post Reply
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Lisp links thread

Post by gilesgoat »

tufty wrote:
gilesgoat wrote:Has anyone ever wrote an .ASM in LISP *hint* *hint*.
Yes.
Can you show me an example/LISP source of some project like that ?

I'd love to see "a practical example of stuff I suppose should come lovely in LISP".
Giles the billy goat
"Baa"
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Lisp links thread

Post by gilesgoat »

tufty wrote:http://common-lisp.net/cgi-bin/viewcvs.cgi/movitz/asm-x86.lisp?rev=1.39&root=movitz&view=auto
Now that is something interesting to study.

Still .. I mean looking at the complexity of the whole thing .. ( looked at all the other sources as well ) still it escapes me
"a little" .. well hum ..

HUM ..
Giles the billy goat
"Baa"
User avatar
teamonkey
Sheepie Whore
Sheepie Whore
Posts: 12082
Joined: Thu Jun 13, 2002 1:07 am 0
XBL Gamertag: itsthetaste
PSN: teamonkey_ca
Contact:

Re: Lisp links thread

Post by teamonkey »

gilesgoat wrote: "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
The input is a string (a data stream) and an indexed array, and the output is an indexed array of array indices. Not linked lists! Strings and arrays (vectors) are secondary data types in scheme whereas in C they are fundamental. So this example doesn't really show off scheme's strengths, more it's weaknesses.

In reality you'd use a library function to parse the string. Also, as I've said before, Scheme's string handling sucks balls. Common Lisp and Clojure are lisps that have loads of useful string features. I'm going to cheat and assume that you've got the first 10 words in a list.

Code: Select all

#lang scheme

(define word-list '("Apple" "Cherry" "Banana" "Nut"))
(define input-words '("Banana" "Monkey" "Banana" "Apple" "Monkey" "Nut" "Cherry" "Monkey" "Banana" "Nut"))

; Return the index of val in list or -1 if not found - note that there's usually a library function for this too
(define (find-index lst val start-index)
  (if (pair? lst)    ; is it a list node? if not we've reached the end of the list
      (if (equal? (car lst) val)  ; (car lst) is the data that the list node lst contains
          start-index
          (find-index (cdr lst) val (+ 1 start-index))) ; recurse - (cdr lst) is the next list node
      -1))  ; not found

; Program proper
(map
 (lambda (word)
   (find-index word-list word 0))
 input-words)
;> (2 -1 2 0 -1 3 1 -1 2 3)
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

gilesgoat wrote:
Now that is something interesting to study.

Still .. I mean looking at the complexity of the whole thing .. ( looked at all the other sources as well ) still it escapes me
"a little" .. well hum ..

HUM ..
An "easier" example to understand might be the picolisp source. The 64 bit version is written in a 64-bit pseudo-assembler, which itself runs on picolisp. Turtles all the way down, baby*. That little mindfuck out of the way, though, the the assmbler instruction set is found here :

http://software-lab.de/doc64/asm

and the assembler itself can be found by uncompressing the source found here http://software-lab.de/picoLisp-3.0.4.tgz and looking at src64/lib/asm.l

Examples of the assembler syntax and so on can be found throughout the src64 directory,

*well, all the way down to the 64-bit platform native implementation of the gnu assembler, anyway.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
adam
Baaaaaa!
Baaaaaa!
Posts: 4418
Joined: Sat Jun 24, 2006 9:15 pm 0

Re: Lisp links thread

Post by adam »

http://www.pugo.org:8080/

a postscript web server (nothing to do with lisp)
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

Ahhh, ps-httpd. The project that inspired me to write my postscript "make any given huge graphic self-tile on any paper size" wrapper.

I'm not sure I'd even understand it now, postscript may be turing complete but it makes for terrifyingly impenetrable code when you've walked away from it for a bit. Where "a bit" might be considered to be any span of time longer than it takes the kettle to boil.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
adam
Baaaaaa!
Baaaaaa!
Posts: 4418
Joined: Sat Jun 24, 2006 9:15 pm 0

Re: Lisp links thread

Post by adam »

:lol:
adam
Baaaaaa!
Baaaaaa!
Posts: 4418
Joined: Sat Jun 24, 2006 9:15 pm 0

Re: Lisp links thread

Post by adam »

User avatar
failrate
Baaaaaa!
Baaaaaa!
Posts: 2354
Joined: Sun May 23, 2004 6:54 am 0
Location: Sandy Eggo
Contact:

Re: Lisp links thread

Post by failrate »

LISP can be as nice or scary as the programmer writing it. I wrote a 2d shmup engine in Scheme, and it was easier than the equivalent C++ code for me. You can determine from the source if I am nice or scary http://www.shmup-dev.com/forum/index.php?topic=1193.0 http://failrate.com/b/voidSniper_source_release_1.zip
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

Nice work. I'd probably go for lispbuilder-sdl, these days. http://code.google.com/p/lispbuilder/.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

Came across this a couple of days ago, it's a nice scripting language based on Lisp with a lot of the cruft cut away. If nothing else, it's worth looking at for its memory management technique, which I've not seen before, and which claims to be deterministic, with no pauses for gc.

http://www.newlisp.org/
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
zip accident
Sheepie Whore
Sheepie Whore
Posts: 13928
Joined: Sun Feb 20, 2005 1:58 pm 0
Location: Bristol, UK

Re: Lisp links thread

Post by zip accident »

tufty wrote:Came across this a couple of days ago,

http://www.newlisp.org/
Interesting, how are they funded?
"My way is the way of not fighting":- the book of Enter the Dragon.
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Lisp links thread

Post by tufty »

Buggered if I know. The bloke that wrote it appears to be some sort of "consultant", which job title can be used to describe an awful lot of things, not all of which are profitable.

It's GPLed, with regular tarballs above and beyond any binary releases, but the source repo doesn't appear to be public. I posit that it's (currently) a more-or-less hobby project. That said, Ruby was a hobby project for Matz for the first few years, so that's not necessarily a bad thing.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Lisp links thread

Post by Dio »

Depending on who he consults for, the funding could easily be "A few months work at £1000/day then the rest of the year for my own projects."
Post Reply