Search found 8 matches

by NickNatra
Wed Dec 21, 2011 1:54 pm
Forum: Common Lisp
Topic: Member using MAP
Replies: 4
Views: 8150

Re: Member using MAP

Thanks for the help
by NickNatra
Tue Dec 20, 2011 1:06 am
Forum: Common Lisp
Topic: Member using MAP
Replies: 4
Views: 8150

Re: Member using MAP

The problem is that i have to use MAP functions, like MAPCAN, MAPCON, MAPCAR
and that's the tricky part. :cry:
So, can you give me some more tips please?
by NickNatra
Mon Dec 19, 2011 2:34 pm
Forum: Common Lisp
Topic: Member using MAP
Replies: 4
Views: 8150

Member using MAP

I must write a function that checks whether an atom is a member of a list not necessarily linear. This is my piece of code, but it works only for linear lists. Can anyone see where I'm wrong? (defun myor(l) (cond ((null l) l) ((atom l) T) ((not (null (car l))) T) (T (myor (cdr l)) ) ) ) (defun membe...
by NickNatra
Tue Dec 06, 2011 10:58 am
Forum: Common Lisp
Topic: Simple issue Trees in Lisp
Replies: 7
Views: 18201

Re: Simple issue Trees in Lisp

After a long struggle i got the expected result.

Code: Select all

(defun convert(l)
   (cond
		((null l) nil)
		(T (cons (car l)  (cons (length(cdr l)) (append (convert (cadr l))(convert (caddr l))))))
   )
)
Thank you for your time.
Your help means a lot to me .
by NickNatra
Tue Dec 06, 2011 8:28 am
Forum: Common Lisp
Topic: Simple issue Trees in Lisp
Replies: 7
Views: 18201

Re: Simple issue Trees in Lisp

i guess this is 90% correct (defun convert(l) (cond ((null l) nil) (T (cons (car l) (cons (cons(length(cdr l))(convert (cadr l)))(convert (caddr l))))) ) ) exept the fact that for this > (convert '(A (B) (C (D) (E)))) the result is (A (2 B (0)) C (2 D (0)) E (0)) and not (A 2 B 0 C 2 D 0 E 0)
by NickNatra
Tue Dec 06, 2011 1:07 am
Forum: Common Lisp
Topic: Simple issue Trees in Lisp
Replies: 7
Views: 18201

Re: Simple issue Trees in Lisp

Yes i'm using common lisp.
Tahks for the help.

Any tips here :

Code: Select all

(defun convert(l)
	(cond
		((null l) nil)
		((atom (car l)) (cons (car l) (length (cdr l))) )
		(T (cons (convert(cadr l)) (convert (caddr l))))
	)
)
:roll: English is not my native language so sorry my bad understanding
by NickNatra
Mon Dec 05, 2011 11:54 am
Forum: Common Lisp
Topic: Simple issue Trees in Lisp
Replies: 7
Views: 18201

Re: Simple issue Trees in Lisp

...A
../. \
.B ..C
..../ \
...D. E

The tree looks like this (corrected).
Hurry please :(
by NickNatra
Mon Dec 05, 2011 10:28 am
Forum: Common Lisp
Topic: Simple issue Trees in Lisp
Replies: 7
Views: 18201

Simple issue Trees in Lisp

Hello, The subject says "simple", but is not really a piece of cake for me :? Please help me( I started learning LISP 5 days ago ). A / \ B C / \ D E A tree can be represented in two ways (A 2 B 0 C 2 D 0 E 0) (1) (A (B) (C (D) (E))) (2) ->Convert a tree of type (2) to type (1). This is my...