lisp

How can I use the Clojure REPL together with Qt Jambi?

I have not found a solution to use the Clojure REPL with Qt on the web. Basically the problem is that the REPL hangs as soon as you call QApplication/exec in order to get the UI to display. You cannot C-c C-c back into the REPL, and closing the active Qt window seems to kill the whole Clojure process. Now simply calling QApplication/pro...

Common Lisp: cons inside loop

I wonder why in the following code, d is not being consed into x. Any hints are much appreciated. (defun it (x) (setq f '(a b c)) (dolist (d f) (cons d x)) (print x)) Thank you! ...

SICP 1.31: Approximating Pi

Hello- I'm working through SICP on my own, so I don't have an instructor to ask about this. This code is supposed to approximate pi but always returns zero instead. (define (approx-pi acc) (define (factors a) (define basic-num (if (= (mod a 2) 0) (/ a 2) (/ (- a 1) 2))) (if (= (mod basic-num ...

Number of levels in a tree in LISP

An n-ary tree is memorised in the following way: (node (list-subtree-1) (list-subtree-2) ...) As an example, the tree A / \ B C / \ D E is represented as follows: (A (B) (C (D) (E))) Return the number of levels of a tree The problem is that I am only allowed to use the following functions: null, car, cdr, equal, atom, ...

Sudoku table generator failure, lisp

Hello. I have a problem with some part of my lisp code. It is a sudoku table generator. It works fine until this part: (loop for e in entries do (if (and (not (member e sub)) (not (member e col))) (progn (setq choices (nconc choices (list e))) (print choices))) (if (= (length choices) 1) ...

scheme and set!

How can I change the value of a variable via a function that consumes lambda parameter? Ie: ;;definitions (define test "fails") (define (experiment input) (set! input "works")) ;;interactions > test "fails" > (experiment test) > test "fails" This seems to fail.. Regards ...

Easy ways to try out and test Lisp syntax?

Clojure has introduced me to the concept of Lisp syntax, and I'm interested, but it's a pain to get the Clojure repl set up and use it on different machines. What other resources are there out there for actually on-the-fly testing and playing with Lisp syntax? I'm imagining something like a website where you can input rudimentary cod...

Picolisp question, segfault when manipulating lists of numbers (from mailing list)

Hello, I'm new to Picolisp. I tried this, and obtained a segfault: : ('(1 2) 6) Segmentation fault But, if i try: : ('(a b c) 6) -> NIL I mostly understand why, but it was a surprise that PicoLisp responded with a segfault instead of an error. Does this means that Picolisp doesn't check if a number is a function but it does when i...

Translating the Q and P function from The Little Schemer into Common Lisp?

In Chapter 9 of the Little Schemer, the Author presents the following two functions (define Q (lambda (str n) (cond ((zero? (remainder (first$ str ) n)) (Q (second$ str ) n)) (t (build (first$ str ) (lambda ( ) (Q (second$ str ) n))))))) (define P (lambda (str) (build (first$ st...

Lisp as a Scripting Language in a C++ app...

Hey, I've been looking at the possibility of adding a scripting language into my framework and I heard about Lisp and thought I would give it a go. Is there a VM for Lisp like Lua and Python or am I in the wrong mindset. I found CLISP here, http://clisp.cons.org/, but am not sure if this is what I am looking for. Can anyone point me in ...

SOAP request from within an AutoLISP/AutoCAD macro

We have built a webservice for a client that uses AutoCAD. They have a macro that runs in AutoCAD that builds a SOAP request. But they have not figured out how to actually send() the soap request to us. So the XML is all proper and ready to go, they just need to send it. Anybody out there familiar enough with AutoLISP to know how to se...

Getting the first n elements of a list in Common Lisp?

The title says it all, really. How would I get the first n elements of a list? CL-USER> (equal (some-function 2 '(1 20 300)) '(1 20)) T I am absolutely certain this is elementary, but help a brother newb out. Kisses and hugs. ...

What does the SBCL time function return?

I'm trying to time an order statistic function implemented in SBCL. Googling around I found this timing function: (time form). However I'm not sure what it returns. It seems to be a large number but I can't find documentation specifying if the return value is milliseconds, nanoseconds, system time, etc. Does anyone know? ...

Calculating the depth of a binary tree in LISP recursively

I have the following binary tree A / \ B C / \ D E represented as a list in Lisp (A 2 B 0 C 2 D 0 E 0) where the letters are node names and the numbers are the number of child nodes (0 for none, 1 one node, 2 two nodes). I need to find highest from root node to leaf depth of the tree (the depth of the binary tree that is)...

How to make a new list to point somewhere else, Lisp

Hello. The title is self-explanatory. How can I build a new list X from another list Y (same structure), but the resulting list pointing somewhere else in memory area, practically, another object? I tried with make-list :initial-element Y or appending to an empty list, but I still get the same object. Thanks! ...

Is there a common lisp package naming convention?

I have created some of my own user packages and have run into a name clash. In Java, the naming convention is to use your domain name in the package name: e.g. import com.example.somepackage;. Are there any widely used package naming conventions for common lisp packages? Regards, Russell ...

lambda-gtk negative pointer

I was trying to write my own put-pixel on (Gdk) pixbuf in Lisp. When I finally realized how I can operate on C pointers in CL, new obstacle came along - (gdk:pixbuf-get-pixels pb) returns me negative number. My question is: can I convert it somehow to a valid pointer? My attempts to use cffi:convert-from-foreign and cffi:translate-from-f...

Scheme - how do I modify an individual element in a list?

If I have a list of 0's, how would I modify, for example, the 16th 0 in the list? ...

Lisp code explanation

I'm porting some code from lisp, but I got stuck at this part (apparently that's for mit-scheme) (define (end-of-sentence? word) (and (or (char-exist-last? word '#\.) (char-exist-last? word '#\!) (char-exist-last? word '#\?)) (not (initial? word)) (or (eq? (peek-char) '#\Space) ;;peek- so test for l...

Collection of solved Lisp problems

Could somebody direct me to an online and free available collection/s or resources of solved and commented (not necessarily) Lisp programming problems, especially related to binary trees and recursion. I tried to Google it up the question but I didn't manage to find anything useful. I need solved problems because in my attempt of learn...