Search found 28 matches
- Wed Oct 24, 2012 7:17 am
- Forum: Common Lisp
- Topic: Binary search tree obscure code...
- Replies: 5
- Views: 18652
Re: Binary search tree obscure code...
Everything is fine in the code, you're just confused by what the call to a struct returns. When you eval nums at the repl, the :print-function defined by defstruct is called and returns a string of the form #<5>, where 5 is the element stored in the main node of your tree. Graham returns a string of...
- Sat Oct 20, 2012 1:54 pm
- Forum: Common Lisp
- Topic: strange error with mapcan and quote.
- Replies: 1
- Views: 4014
strange error with mapcan and quote.
I get a weird behavior with sbcl when I try the following code at the repl. (mapcan (lambda (x) (if (evenp x) '(even))) (list 1 2 3 4)) Sbcl hangs at 100% CPU without returning an error. Why do I get such a behavior? Apparently, this is related to the quote '(even). If I replace it by (list 'even), ...
- Fri Oct 19, 2012 1:38 am
- Forum: Common Lisp
- Topic: loop keywords
- Replies: 4
- Views: 9021
Re: loop keywords
Ah, I understand now. Thanks for the thorough answer.
- Thu Oct 18, 2012 1:20 am
- Forum: Common Lisp
- Topic: loop keywords
- Replies: 4
- Views: 9021
loop keywords
Hi, I see sometimes loop forms written as follows. (loop :for x :from 1 :to 10 :collect x) Why do some people prefix the loop keywords with a colon? Is this required by some implementations? The hyperspec insists on the fact that "Loop keywords are not true keywords." So why does the use o...
- Thu Oct 18, 2012 1:01 am
- Forum: Common Lisp
- Topic: fractional part of a number
- Replies: 3
- Views: 6497
Re: fractional part of a number
Thanks for the replies, this is definitely better.
- Mon Oct 15, 2012 1:35 pm
- Forum: Common Lisp
- Topic: fractional part of a number
- Replies: 3
- Views: 6497
fractional part of a number
Hi,
Is there a simple way to return the fractional part of a number in common lisp?
At the moment I am using
but this seems a bit verbose.
Is there a simple way to return the fractional part of a number in common lisp?
At the moment I am using
Code: Select all
(multiple-value-call (lambda (x y)(declare (ignore x)) y) (floor 1.5))
- Mon Oct 15, 2012 8:50 am
- Forum: Common Lisp
- Topic: true function
- Replies: 3
- Views: 6137
Re: true function
This does not give exactly the same result.
So I guess there is no builtin true function.
Anyway, thanks for the answer.
Code: Select all
CL-USER> (some 'identity (list nil "no" nil))
=> "no"
CL-USER> (notevery 'not (list nil "no" nil))
=> T
Anyway, thanks for the answer.
- Sat Oct 06, 2012 6:23 am
- Forum: Common Lisp
- Topic: true function
- Replies: 3
- Views: 6137
true function
Hi, is there a "true" function in Common Lisp ? I mean does there exist a function that returns t for all non nil values of its argument, and nil if its argument is nil? There are at least two "false" functions, not and null, which are strictly equivalent, but I was not able to l...