lisp

Problem with access of slots in Lisp (CLOS)

I have a Node class that has an 'element' slot which contains a list with numbers and one letter, for example: '(1 2 3 b 4 5 6) (defclass node () ((element :reader get-element :writer set-element :initform '() :initarg :element :documentation "The element")) Part of the program is su...

Why is read-line run twice for reading from a file in Lisp?

This is the code to implement the 'cat' command with lisp, as is explained in the book ANSI Common Lisp, page 122. (defun pseudo-cat (file) (with-open-file (str file :direction :input) (do ((line (read-line str nil 'eof) (read-line str nil 'eof))) ((eql line 'eof)) (format t "~A~%" line)))) Why is ...

How to do Pattern Matching in Common Lisp

I have no idea if there exists a pattern matching function for Common Lisp, nevertheless I have to make my own function. I have no idea about Lisp. Can somebody give heads-up on learning Lisp and most importantly, how to go about doing pattern matching in Lisp. I will have to pass a pattern and a fact and say if they match. An example wo...

SICP, Scheme, DrRacket Question: Timer/profiler function?

I'm currently trying to do exercise 1.22, which needs a function called runtime that returns the number of milliseconds the system has been running. However, my environment (R5RS) does not seem to have this. It does not have time, current-milliseconds, current-inexact-milliseconds, etc, either. What function do I have access to, to pro...

How to return control from a function in lisp

(defun returnFirstCharacter(p) (if (symbolp p) (char (symbol-name p) 0) nil) ) (defun returnRestCharacters (p) (let () (intern (subseq(string p) 1)) ) ) (defun val (x a) (cond ((null a) nil) ((equal (car(cdr a)) x) (cdr (cdar a))) (t (val x (cdr a))) ) ) (defun match (pattern data) (cond ...

Can call-with-current-continuation be implemented only with lambdas and closures?

Does anyone know if call/cc can be implemented with just lambdas and closures? It seems that call/cc interrupts the program's flow (like an exception) but lambdas and closures can't do that. Therefore I think call/cc can't be implemented via lambdas and closures. Any more ideas? ...

How can I read the contents of a file into a list in Lisp?

I want to read in the contents of a file into a list. Some of my attempts so far have been - (defun get-file (filename) (let ((x (open filename))) (when x (loop for line = (read-line x nil) while line do (list line))) (close x))) (defun get-file (filename) (let ((x (open filename :if-does-not-exist nil)) (content...

Struggling with common lisp libraries

I've learned scheme and quickly mastered a lot of it, then did a project in it just fine. Literally took me days to finish. I'm now trying to learn common lisp to get a feel for that and now I'm just really really struggling with trying to learn asdf. It seems to be common knowledge how to use it with libraries but I'm baffled. I guess i...

How to make and use library with lisp (clisp)?

In C/C++, I can make a library, and make it static one or dll using #include "" in source code, and -labc when linking. How do I have the same feature in lisp? As an example of util.lisp in directory A. I define a library function hello. (defpackage "UTIL" (:use "COMMON-LISP") (:nicknames "UT") (:export "HELLO")) (in-package ut...

How to go about learning Common Lisp and Emacs Lisp?

The last few months I've been using Emacs extensively as my main development environment and I've now come to a point at which I'd like to learn it's own Emacs Lisp to write my own little stuff for Emacs and extend it to my personal needs. Having said that I've also wanted to learn Common Lisp for a while now, to play around with and ex...

What is WITH-STANDARD-IO-SYNTAX macro for?

The Practical Common Lisp page 25, explains the WITH-STANDARD-IO-SYNTAX as follows. "It ensures that certain variables that affect the behavior of PRINT are set to their standard values". The usage is as follows. (with-open-file (...) (with-standard-io-syntax (print ... Should (print) be used in this macro? If not, what ...

How can I use external variables in eval in Scheme?

I am trying something out in Scheme for fun. I'm trying to make an Area function that gets the type of the thing it's operating on and then calls a different function depending on the type of object. Here's my code: (define (area object) (if (not (null? (eval (word 'area- (get-type object))))) (eval (list (word 'area- (get-typ...

How can I check if a variable exists in Scheme?

Is there a way to check if a variable exists in Scheme? Even doing things like (if variable) or (null? variable) cause errors because the variable is not defined. Is there some function that returns whether or not a variable exists? ...

Help with installing ECL (Embeddable Common Lisp) via mingw32 or mingw-64 on Win7-64

I'm trying to compile ECL 10.4.1 on my Win7 64-bit box, but am having issues. I've attempted the build with both mingw32/MSYS and mingw-w64/MSYS, using the exact packages linked to here. Both have failed. With mingw32: ./configure passes, make fails as follows: gcc -DECLDIR="\"/usr/local/lib/ecl-10.4.1\"" -I. -Ic:/my_home/ecl-10.4.1/...

Increase Minimum Stack Overflow Size in Mac Common Lisp 5.0

Hi, I'm relatively new to Lisp (I just know the very basics) and I'm currently trying to run an algorithmic composition program created by David Cope. It runs in MCL 5.0, and I keep getting the following error: Error in process play: Stack overflow on value stack. To globally increase stack space, increase *minimum-stack-overflow-...

How does Java drag C++ coders "halfway to Lisp?"

Possible Duplicate: How is Java inspired by Lisp? From Paul Graham: "We were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp." Guy Steele, co-author of the Java spec I've thought about this, and it just doesn't make any sense. Out of all the "Lisp-ish" features on Graham'...

Opening an HTML page in a browser from Common Lisp

My Common Lisp program writes out an HTML file. I then want to launch this file in the user's default browser. Is there a way of doing this in Common Lisp? Moreover, is there an OS-independent way of doing this? ...

Emacs Lisp: Can't set any value to variable named 's'

This is rather queer. I can't set any value to a variable if it is named 's' in an interactive session: (setq s 'foo) => foo s => nil Why? Update 1: Here is the output from describe-variable on s: s is void as a variable. Documentation: Not documented as a variable. Why is it that s is kept void in emacs lisp as a global variab...

setq and defvar in lisp

I see that the Practical Common Lisp uses (defvar *db* nil) for setting up global variable. Isn't it OK to use setq for the same purposes? What's the advantages/disadvantages of using defvar vs setq? ...

Lisp's apply and funcall vs Python's apply

Lisp's apply is for Lisp's APPLY is for calling functions with computed argument lists stored in lists.(Modified from Rainer's comment) For example, the following code changes (list 1 2 3) to (+ 1 2 3). (apply #'+ '(1 2 3)) However, Python's apply does what Lisp's funcall does, except for some minor differences (input is given as t...