Can you show me an example/LISP source of some project like that ?tufty wrote:Yes.gilesgoat wrote:Has anyone ever wrote an .ASM in LISP *hint* *hint*.
I'd love to see "a practical example of stuff I suppose should come lovely in LISP".

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

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

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.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
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)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 :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 ..

Interesting, how are they funded?