Search found 35 matches

by danb
Tue Dec 27, 2011 4:18 pm
Forum: Common Lisp
Topic: Example sourcecode for a speech
Replies: 4
Views: 6072

Re: Example sourcecode for a speech

If you're giving a speech on functional programming, why don't you present examples of functional code?
by danb
Sat Mar 07, 2009 12:06 am
Forum: Common Lisp
Topic: LISP Tutorial Help
Replies: 6
Views: 10756

Re: LISP Tutorial Help

Wodin wrote:
danb wrote:and if they're both null, then return the symbol ITS-TOUGH."
This should be "and if neither of them is null, then return the symbol ITS-TOUGH." :)
You're right. I may have meant to say "non-null".
by danb
Thu Feb 19, 2009 8:56 pm
Forum: Common Lisp
Topic: Help me, grapich function in Lisp
Replies: 2
Views: 5280

Re: Help me, grapich function in Lisp

I don't know much about the details, but you can look for stuff here:
Graphics toolkits
Graphics libraries
by danb
Sat Feb 14, 2009 1:35 pm
Forum: Common Lisp
Topic: LISP Tutorial Help
Replies: 6
Views: 10756

Re: LISP Tutorial Help

(defun life (a b) (cond ((null a) b) ((null b) a) (t 'its-tough))) >(setf a 'oh-boy) >(life 'gummi a) What are the global and local values of a and b before, during, and after this command? plandr, I can help you with your homework if you need a tutor. I won't do your homework for you, but I can ma...
by danb
Mon Feb 02, 2009 8:21 am
Forum: Common Lisp
Topic: A procedure to extract atoms from a list
Replies: 11
Views: 23288

Re: A procedure to extract atoms from a list

I'm not so sure I'm happy about seeing flatten as a necessity here. You're right. The OP was asking if flatten + remove-dups is sufficient, and I meant "all you need to do" in the sloppy colloquial sense of "yes, that's sufficient". While I recognize a place for programming para...
by danb
Mon Feb 02, 2009 7:44 am
Forum: Common Lisp
Topic: [Newbie] Help needed for basic problem
Replies: 8
Views: 11248

Re: [Newbie] Help needed for basic problem

the textbook says that we can solve the problem using only do That's right. DO is an all-purpose iteration macro, and DOLIST is specialized for lists. (dolist (x list) < insert the body of your code here >) is almost equivalent to this: (do ((cell list (cdr cell))) ((not cell)) (let ((x (car cell))...
by danb
Sun Feb 01, 2009 6:20 am
Forum: Common Lisp
Topic: [Newbie] Help needed for basic problem
Replies: 8
Views: 11248

Re: [Newbie] Help needed for basic problem

I have been trying to write a function that will allow me to return the smallest number of a list. It is an exercice to practice "do" iteration. Use DOLIST to iterate over a simple list. Could somedy hint me on how to get started with that function? Basically, you start with the first ele...
by danb
Sun Jan 25, 2009 11:34 am
Forum: Common Lisp
Topic: pos+ function from Paul Graham's "ANSI Common Lisp"
Replies: 12
Views: 22292

FP

Ajschylos wrote:that's really piece of beautiful code.
That's functional programming :P You can write code like that for lots of applications. It tends to be a little slower and more memory-intensive than imperative code, but once you get used to FP, hard programs can actually be both fun and easy.
by danb
Sun Jan 25, 2009 2:13 am
Forum: Common Lisp
Topic: pos+ function from Paul Graham's "ANSI Common Lisp"
Replies: 12
Views: 22292

Re: pos+ function from Paul Graham's "ANSI Common Lisp"

(defun pos+ (l) (let ((i -1)) (mapcar #'(lambda (x) (incf i) (+ x i) ) l ))) I don't like this code, can anybody suggest more elegant solution? If you're going to use MAPCAR, you might as well write a functional solution. That means no INCF, at least not in the toplevel function. Instead, write ano...
by danb
Sun Jan 25, 2009 1:48 am
Forum: Common Lisp
Topic: A procedure to extract atoms from a list
Replies: 11
Views: 23288

Recursion

will two procedures be enough for the whole program? Yes. All you need to do is flatten the tree and remove all duplicates. I am rather new to Lisp ... Could you tell me a little more about that flatten function? How much do you know about recursion and functional programming? FLATTEN is a great ex...