Search found 62 matches

by Konfusius
Fri Sep 13, 2013 5:11 am
Forum: Common Lisp
Topic: Some basic lisp functions -trying to teach myself the basics
Replies: 12
Views: 25851

Re: Some basic lisp functions -trying to teach myself the ba

Code: Select all

(defun filter (lst items-to-filter)
  (loop for x in items-to-filter
        if (not (member x lst))
          collect x))
by Konfusius
Fri Mar 08, 2013 4:56 am
Forum: Common Lisp
Topic: newbie question: floating point addition operation
Replies: 8
Views: 15234

Re: newbie question: floating point addition operation

You can convert rationals to floats:

Code: Select all

(float (+ 232/100 1/1000))
-> 2.321
by Konfusius
Tue Mar 05, 2013 2:30 am
Forum: Common Lisp
Topic: newbie question: floating point addition operation
Replies: 8
Views: 15234

Re: newbie question: floating point addition operation

Since floating point numbers are represented internally as numbers by the base of two there isn't a way to represent 0.001 exactly. There will always be rounding errors. This isn't a problem of Lisp but of floating point arithmetic in general. The only way around it is to print it rounded: (format t...
by Konfusius
Sun Dec 09, 2012 1:14 am
Forum: Common Lisp
Topic: symbol-function
Replies: 2
Views: 6695

Re: symbol-function

You may think of a symbol as having two slots, one for the variable value and one for the functional value. If the evaluator encounters a symbol then it looks up the variable value. But if it encounters a form like (sym args ...) then it looks up the functional value for sym and calls that function ...
by Konfusius
Fri Nov 30, 2012 6:42 am
Forum: Common Lisp
Topic: refined common lisp
Replies: 6
Views: 14435

Re: refined common lisp

IMO, throwing away the standard just to rename a few functions isn't a good idea. Cleanning up CL by adding features won't work. Cleaning up CL by making it community driven is a contradiction in itself. To justify a new common lisp the community had to come up with serious new language design ideas...
by Konfusius
Fri Nov 30, 2012 5:27 am
Forum: Common Lisp
Topic: macro expansion within macro
Replies: 5
Views: 15010

Re: macro expansion within macro

Macro forms are expanded only at places where a function call may be placed. Since (COND (COND-CLAUSE (= C 8) 1)) didn't work if COND-CLAUSE was a function it also doesn't work if its a macro.
by Konfusius
Wed Nov 21, 2012 5:01 pm
Forum: Common Lisp
Topic: Classes of functions?
Replies: 2
Views: 5299

Re: Classes of functions?

If you are looking for a way to determine the lambda list of a function then: yes, it's possible. But its implementation dependent. For example, in Clozure CL you can determine the lambda list with ccl:arglist:
? (ccl:arglist #'mapcar)
->(FUNCTION LIST &REST CCL::MORE-LISTS)
by Konfusius
Tue Nov 20, 2012 4:42 pm
Forum: Common Lisp
Topic: Apply a method
Replies: 4
Views: 8652

Re: Apply a method

underablackrainbow wrote:Hi. Can someone tell me if a method can be used outside of a generic function?
Yes. They can be used just like ordinary functions.

EDIT: this is nonsense. i mixed up methods with generic functions.
by Konfusius
Sun Nov 18, 2012 6:53 am
Forum: Common Lisp
Topic: on &rest and keyword args...
Replies: 11
Views: 24473

Re: on &rest and keyword args...

ok thanks for reporting and fast explanation !! then when I define a func with &rest and also keyword parameters , I can pass it only keyword args… because it can’t accept (in this case) a variable number of arguments….right?... Yes. but ther’s a way to mix ‘really’ &rest and &a...
by Konfusius
Sat Nov 17, 2012 2:45 pm
Forum: Common Lisp
Topic: on &rest and keyword args...
Replies: 11
Views: 24473

Re: on &rest and keyword args...

&key may be seen as the same as &rest but with an extra convinience feature of parsing the rest argument as a list of key/value pairs. Common Lisp allows you to use &rest together with &key because sometimes you want to pass on the keyword arguments to another function unchanged. For...