So, I was stuck trying to learn this language of the Scheme that I heard about from a friend of mine. What he said, what I have to do is to start small and work to understand him. Therefore, after reading a tutorial, which he briefly talked about programming Schemes, I am a little puzzled by how this works.
To a large extent, I am trying to ask that if I wanted to add a definition to the function being called, say βevensβ from the pair of lists that I defined:
(DEFINE list0 (LIST 'j 'k 'l 'm 'n 'o 'j) ) (DEFINE list1 (LIST 'a 'b 'c 'd 'e 'f 'g) ) (DEFINE list2 (LIST 't 'u 'v 'w 'x 'y 'z) ) (DEFINE list3 (LIST 'j 'k 'l 'm 'l 'k 'j) ) (DEFINE list4 (LIST 'n 'o 'p 'q 'q 'p 'o 'n) ) (DEFINE list5 '((ab) c (ded) c (ab) ) (DEFINE list6 '((hi) (jk) l (mn)) ) (DEFINE list7 (f (ab) c (ded) (ba) f) )
so that it performs the following task: evens
which I have already created an adder function, which I suppose should be:
(DEFINE (adder lis) (COND ((NULL? lis) 0) (ELSE (+ (CAR lis) (adder (CDR lis)))) ))
, which could even be for determining if I wanted this to be performed as a task below:
Evens: (evens 1st) should return a new list formed of even elements made by 1st.
(evens '(abcdefg)) which would/should return: (bdf)
and
(evens (LIST 't 'u 'v 'w 'x 'y 'z)) which would/should return: (tvxz)
and
(evens '(f (ab) c (ded) (ba) f) ) which would return: ((ab) (ded) f)
and both (evens '()) and (evens' (a))
will return an empty list.
I walk the trail by mistake to practice, but I am completely lost. thanks in advance
Ok, I think I came up with a recursive function for my example, which I was trying to solve:
(define mylist '(1 2 3 4 5 6 7)) (define (evens lst) (define (do-evens lst odd) (if (null? lst) lst (if odd (do-evens (cdr lst)
any thoughts?