Search found 35 matches

by danb
Wed Dec 31, 2008 9:46 pm
Forum: Common Lisp
Topic: REPL problems in Lisp
Replies: 12
Views: 16089

The REPL calls EVAL

The difference is that there are two evaluations in (eval '(a b)). When you type (eval '(a b)) into the repl, the call to READ in the repl turns the string '(a b) into the form (quote (a b)), and the call to EVAL (still in the repl) evaluates the quote form and returns the list (a b). Now your expli...
by danb
Mon Dec 29, 2008 4:20 am
Forum: The Lounge
Topic: What feature would you most like to see in Lisp?
Replies: 43
Views: 70325

(setf if)

A (setf if) macro would be nice, so you can say

Code: Select all

(let (goods bads)
  (dolist (x xs)
    (push x (if (goodp x) goods bads))))
by danb
Sat Dec 27, 2008 2:54 pm
Forum: The Lounge
Topic: A TRUE NEWBIE
Replies: 3
Views: 6848

Re: A NEWBIE INDEED

gaitdoctor wrote:I AM TRUELY A NEWBIE.... THE GUYS WHO GET IT EASY, DON'T GET IT WHY SOME DON'T.
WHAT ARE YOU HAVING TROUBLE WITH?
by danb
Sat Dec 27, 2008 2:28 pm
Forum: Common Lisp
Topic: Deleting a sequence from a list
Replies: 3
Views: 9843

Re: Deleting a sequence from a list

I have just entered the world of LISP so I'm a bit of a newbie! Welcome 8-) I want to change a list containing something like (2 x + 1) into something like (2 x) i.e. I want to find and delete all (+ 1)s in a list. Walk down the list, checking each cdr (ie. remainder) of the list to see if it start...
by danb
Thu Dec 25, 2008 3:07 pm
Forum: Common Lisp
Topic: Breadth First Search
Replies: 1
Views: 6988

Successors

(defun set-adj (x y) (setf (gethash x Breadth-info) y) ) (defun get-adj (x) (gethash x Breadth-info) ) (set 'A '(B C)) (defun successors (n) (get-adj n) ) You're never calling SET-ADJ, so GET-ADJ is returning NIL. This seems to work with the rest of your implementation: (defun successors (n) (symbo...
by danb
Thu Dec 25, 2008 3:58 am
Forum: Common Lisp
Topic: accept both numbers and letters
Replies: 4
Views: 10574

Re: accept both numbers and letters

how can i use the defmacro in order to simplify any given polynomial e.g (x + y)(x + y) → x2 + 2xy + y2 There's some code here . You don't need a macro if you're doing the simplification at runtime. You just quote the arguments, as in (simplify '(* (+ x 1) (+ x -1))). Once a product is expanded, ...
by danb
Fri Dec 12, 2008 10:06 pm
Forum: Common Lisp
Topic: Looking for good examples of Lisp macros
Replies: 6
Views: 13688

Re: Looking for good examples of Lisp macros

There are a couple simple reader macros here . One is a sort of multi-purpose infix/postfix/message-passing syntax, and the other one fakes partial function application. There are more macros in the standard library and the pattern-matching library that are linked from that page, but non-Lispers see...
by danb
Tue Dec 02, 2008 11:22 am
Forum: Common Lisp
Topic: changing argument variables
Replies: 10
Views: 20091

Re: macros

(defun hello (x) (setf x 6)) (setf y 3) (hello y) How can I make it so that so that the value of y is changed to 6??? This operates on a place, so it would be a macro: CL-USER> (defmacro setf-6 (place) `(setf ,place 6)) SETF-6 CL-USER> (let ((x 3)) (setf-6 x) x) 6
by danb
Thu Nov 06, 2008 10:23 am
Forum: Common Lisp
Topic: IF/WHEN?
Replies: 6
Views: 12036

Re: IF/WHEN?

If you're only using B as a boolean, you should write (and a b).
by danb
Tue Oct 07, 2008 2:49 am
Forum: Common Lisp
Topic: How to turn function into a list?
Replies: 11
Views: 24266

Re: How to turn function into a list?

In the macro chapter of Ansi common lisp it's explained that using string list manipulation and eval to create macro like behavior, such as I suggested, is almost never used, because 1) doing it that way doesn't allow the use of lexical content, and 2) making eval compile or interpret a raw list is...