Search found 18 matches

by Ajschylos
Thu Mar 19, 2009 8:12 am
Forum: Common Lisp
Topic: Recursive macro.
Replies: 6
Views: 6745

Re: Recursive macro.

Hi again, I know perfectly well how to do this using functions ( the dolist construct was my first idea) I want to do it using macros, and especially NCR macro I wrote from many purposes, mainly training. So I am very obliged for Your time spent convincing me that macro is not good solution, I am lo...
by Ajschylos
Thu Mar 19, 2009 1:56 am
Forum: Common Lisp
Topic: Recursive macro.
Replies: 6
Views: 6745

Recursive macro.

Hi, for last several weeks I've tried to understand macros, especially their arguments evaluation. I need such construct in my project: (n-mapcar #'( lambda ( < variables-list > ) (< and-body-of-function-to-execute >)) '(< over-several-lists-of-arguments >)) Why I call this n-mapcar? Simply because ...
by Ajschylos
Sat Feb 28, 2009 4:50 pm
Forum: Common Lisp
Topic: CLisp Programming LISP program that produce a mirrored list
Replies: 20
Views: 13104

Re: CLisp Programming LISP program that produce a mirrored list

Should not You assume that (mirror '(a.b)) returns (b.a)

That's quite a question, I suppose.

And find an elegant solution!
A.
by Ajschylos
Tue Feb 17, 2009 3:40 am
Forum: Common Lisp
Topic: Short about 'sort'
Replies: 10
Views: 10125

Re: Short about 'sort'

Ramarren, I am not sure that I understand You well, as I suppose, sort might destroy the sorted entity, not the relation predicate expressed in lambda form, am I right?
by Ajschylos
Mon Feb 16, 2009 2:21 pm
Forum: Common Lisp
Topic: Short about 'sort'
Replies: 10
Views: 10125

Short about 'sort'

Hello again, my progress in Lisp is continuing mainly thanks to your help. Thanks a lot. Now there is small question. I want to sort a list of following shape: ((a1 x1 (something1)) (a2 x2 (something2)) ... (an xn (something))) using predicate (< ai aj) for any i, j. I did it following way: (sort '(...
by Ajschylos
Mon Feb 09, 2009 3:56 am
Forum: Common Lisp
Topic: problem with &rest
Replies: 8
Views: 8787

Re: problem with &rest

Now my function works: (defun app-sym (&rest l) (labels (( a-s (x) (let ((el (car x))) (if (null x) nil (cond ((listp el) (append el (a-s (cdr x)))) ((atom el) (append (list el) (a-s (cdr x)))) (T nil)))))) (a-s l))) Surely it's not so efficient as yours, but it let me train some recursion. Thanks f...
by Ajschylos
Mon Feb 09, 2009 2:58 am
Forum: Common Lisp
Topic: problem with &rest
Replies: 8
Views: 8787

Re: problem with &rest

Ok. dmitri, now I understand my mistake.
Thanks.
A.
by Ajschylos
Sun Feb 08, 2009 10:33 pm
Forum: Common Lisp
Topic: problem with &rest
Replies: 8
Views: 8787

Re: problem with &rest

Dmitry, Your solution looks cute, and it works.

I see that I've run into an infinite loop, but still do not understand why.

The test (if (null lst) nil "else" ... do sth.) should work if the parameter after &rest is an ordinary list as suggests Ramaren, but it does not.
by Ajschylos
Sun Feb 08, 2009 10:26 pm
Forum: Common Lisp
Topic: problem with &rest
Replies: 8
Views: 8787

Re: problem with &rest

Hi Ramaren, you seem to understand perfectly well, your solution works like I want,
but I am interested in recursive solution, and I would like to know why my function doesn't work.

Thanks anyway, A.
by Ajschylos
Sun Feb 08, 2009 12:33 pm
Forum: Common Lisp
Topic: problem with &rest
Replies: 8
Views: 8787

problem with &rest

Hi, I need a function which appends either lists and atoms into one list. I've tried many variations on something like this: (defun app-sym ( &rest lst) (if (null lst) nil (cond ((atom (car lst)) (append (list (car lst)) (app-sym (cdr lst)))) ((listp (car lst)) (append (car lst) (app-sym (cdr lst)))...