lisp

Returning an element from a list

I'm trying to learn lisp and as i'm making my first steps i got stuck. How can i get c element form following list: (a b (c.d)) I've tried: (caar (last '(a b (c.d)))) but it returns c.d and not only c This however works if there are spaces between c, . , d ie: (caar (last '(a b (c . d)))) The problem i'm trying to resolves has the li...

What is the smallest Lisp-ish interpreter? Compiler?

I'm looking at ways to embed Lisp or Scheme in a C program, but I want to do so without growing the program size considerably. It doesn't need to be fast, or support lots of features. (Though macros would be nice.) This is not a math-intensive application. Please list the smallest embeddable interpreter for a Lisp-like language you k...

What does "my other car is a cdr" mean?

Can anyone well versed in lisp explain this joke to me? I've done some reading on functional programming languages and know that CAR/CDR mean Contents of Address/Decrement Register but I still don't really understand the humour. ...

SBCL standard library documentation?

I want to learn and use SBCL because of its ease of learning and speed. (I've been playing with Lisp 3 years ago, and now am refreshing it.) But how can I learn what's included in the standard library, so that I don't re-implement things? After Python this is like a nightmare: the SBCL website has a manual that covers the software only,...

Homework: Lisp items that appear more than once in a list

Given a list, I'm trying to return a new one that has only the items that appear more than once in the first list I receive as a parameter. I have done the following: (defun myf (lista) (if (endp lista) nil (if (member (first lista) (rest lista)) (append (list (first lista)) (myf (rest lista))) (myf (r...

Compiling to idiomatic C

Are there any compilers out there for function or lisp-ish languages that compile to idiomatic C? Most compilers out there seem to provide something resembling a machine language composed of C macros. I'm wondering if there is anything out there that can produce readable C code based on a higher-level language. ...

Elisp function returning mark instead of the right value

I'm writing a routine to test to see if point is at the practical end of line. (defun end-of-line-p () "T if there is only \w* between point and end of line" (interactive) (save-excursion (set-mark-command nil) ;mark where we are (move-end-of-line nil) ;move to the end of the line (let ((str (buffer-substring (ma...

How can Lisp make me a better C# developer?

I'm considering learning a Lisp dialect (probably Scheme, since I am constantly hearing how good of a learning language it is) in order to improve my general programming skill. Apart from the fact that learning any new language helps you to be a better programmer in general, how can learning Lisp make me a better C# programmer? ...

Another Lisp function refinement

I've completed the Graham's exercise Chapter 5.8,and my code is: (defun max-min (vec &key (start 0) (end (length vec))) (cond ((eql start (1- end)) (values (elt vec start) (elt vec (1- end)))) ((zerop end) (values nil nil)) (t (multiple-value-bind (x y) (max-min vec :start (1+ start) :end end) (let* ((maxx ...

How do I write all-but-one function in Scheme/LISP?

Can you guys think of the shortest and the most idiomatic solution to all-but-one function? ;; all-but-one ;; checks if all but one element in a list holds a certain property ;; (all-but-one even? (list 1 2 4)) -> true ;; (all-but-one even? '(1)) -> true ;; (all-but-one even? '(2 4)) -> false Edit: all but EXACTLY one. ...

How can I write a function in CLisp and call it in C?

Thanks for answering. ...

Debugging what this LISP Virus is doing

My firm has been hit by an AutoCAD virus that is deleting and replacing our acaddoc.lsp with the routine below. I'm an architect and not exactly sure what this is doing by the repetitive "find" and "deletes". Questions What is this replacing the files with (currently searching for acadapq) ? Who writes a virus for AutoCAD?!?! ...

Mystified by end-of-file condition in common lisp

cann't read text file. READ: input stream #1=# has reached its end [Condition of type SYSTEM::SIMPLE-END-OF-FILE] what means is "has reached its end." ...

Elephant database

hi, I am a new user to elephant can you please advice me how to start my work , actually a little source code will be helpfull. ...

More explanation on Lexical Binding in Closures?

There are many SO posts related to this, but I am asking this again with a different purpose I am trying to understand why closures are important and useful. One of things that I've read in other SO posts related to this is that when you pass a variable to closure, the closure starts remembering this value from then onwards. Is this the...

lisp-style style `let` syntax in Python list-comprehensions

Consider the following code: >>> colprint([ (name, versions[name][0].summary or '') for name in sorted(versions.keys()) ]) What this code does is to print the elements of the dictionary versions in ascending order of its keys, but since the value is another sorted list, only the summary of its first element (the 'm...

Functional Programming: what is an "improper list" ?

Could somebody explain what an "improper list" is? Note: Thanks to all ! All you guys rock! ...

Assigning the result of an expression to a variable

Working with DrScheme (language-- Pretty Big). Trying to pass the result of an expression to a variable that can later be used in another expression. Here is a simplified version of the problem: Definitions window: (define (tot a b c) (+ a b c)) (define (tot2) (+ (tot a b c) 1)) Interpreter window > (tot 5 6 7) 18 > (tot2) . ....

How to write an interpreter?

I have decided to write a small interpreter as my next project, in Ruby. What knowledge/skills will I need to have to be successful? I haven't decided on the language to interpret yet, but I am looking for something that is not a toy language, but would be relatively easy to write an interpreter for. Thanks in advance. ...

Exclusive OR in Scheme

What is the exclusive or functions in scheme? I've tried xor and ^, but both give me an unbound local variable error. Googling found nothing. ...