Search found 78 matches

by David Mullen
Wed Jan 10, 2018 3:51 pm
Forum: Homework
Topic: Solved- append a new atom upon finding specific atom
Replies: 1
Views: 17889

Re: Solved- append a new atom upon finding specific atom

You're close—it just wants to be flipped inside out a little bit—the second clause should be like this:

Code: Select all

((EQ (car L) OLD) (cons OLD (cons NEW (appendConst OLD NEW (cdr L)))))
by David Mullen
Sun Dec 31, 2017 5:21 pm
Forum: Common Lisp
Topic: Help with Objects/Functions with arguments
Replies: 2
Views: 22847

Re: Help with Objects/Functions with arguments

with-slots is useful for accessing slots: (defun Damage (Moves Pokemon) (with-slots (BASEDMG) Moves (with-slots (ATK DEF) Pokemon (+ (/ (* (* (+ (/ 100 5) 2) BASEDMG) (/ ATK DEF)) 50) 2)))) It's common in Lisp to use accessors and initargs rather than dealing with slots directly, depending on how &...
by David Mullen
Tue Dec 26, 2017 2:20 pm
Forum: Common Lisp
Topic: Read Text File In Current Directory
Replies: 6
Views: 45931

Re: Read Text File In Current Directory

With Clozure CL, I can set *default-pathname-defaults* (or the working directory, via CCL:CURRENT-DIRECTORY) in the ccl-init.lisp file, which is in my home directory:

Code: Select all

? (probe-file "~/ccl-init.lisp")
#P"C:/Users/David Mullen/ccl-init.lisp"
by David Mullen
Fri Oct 27, 2017 3:24 pm
Forum: Common Lisp
Topic: delete does not work
Replies: 12
Views: 40017

Re: delete does not work

It says something about the appeal and tractability of Lisp's lists that we're talking about million-element lists. I mean, you could argue for a vector because that would halve the per-element overhead. But it's kind of hard to beat the sheer handiness of lists. It's why we all (most of us, anyway)...
by David Mullen
Tue Oct 24, 2017 1:52 pm
Forum: Common Lisp
Topic: delete does not work
Replies: 12
Views: 40017

Re: delete does not work

I use these: (eval-when (:compile-toplevel :load-toplevel :execute) (defun get-removal-macro-expansion (item place options environment function-name) (multiple-value-bind (temps vals news writer reader) (get-setf-expansion place environment) (let ((modification-form `(,function-name ,item ,reader ,@...
by David Mullen
Fri Oct 06, 2017 11:28 am
Forum: Common Lisp
Topic: Pick and remove
Replies: 6
Views: 17355

Re: Pick and remove

Well, now I'm curious—what is this thing: a set-like or queue-like thing? Is there a heuristic for picking a particular element?
by David Mullen
Wed Oct 04, 2017 10:54 am
Forum: Common Lisp
Topic: Pick and remove
Replies: 6
Views: 17355

Re: Pick and remove

DELETE is of course a generic sequence function. But you said "list" so here's one (destructive) solution with list-bashing specificity: (defun pick (index list) (check-type index fixnum) (loop for prev = nil then tail for count fixnum from 0 for tail on list when (= count index) return (p...
by David Mullen
Sun Sep 17, 2017 12:17 pm
Forum: Homework
Topic: Determine number of arguments for a function
Replies: 8
Views: 32870

Re: Determine number of arguments for a function

In Clozure CL:

Code: Select all

(defun required-parameters (function)
  (loop for thing in (ccl:arglist function)
        until (member thing lambda-list-keywords)
        collect thing))
by David Mullen
Thu Sep 07, 2017 1:43 pm
Forum: The Lounge
Topic: hello, i find "LISP" to be frustrating
Replies: 5
Views: 28847

Re: hello, i find "LISP" to be frustrating

It might be nice if there were a Super Lisp, subsuming the various dialects and implementations—but that would imply convergence on a whole set of trade-offs, agreement on how to standardize the (currently non-standard) extensions, in particular: the Foreign Function Interface, etc., while still l...
by David Mullen
Thu Sep 07, 2017 1:13 pm
Forum: The Lounge
Topic: Is there anyone who can teach me lisp?
Replies: 2
Views: 19432

Re: Is there anyone who can teach me lisp?

Is this written for a particular Lisp implementation?