Hello all,
I had to write a program that would take a list and check for alternate atoms and list, if there were two atoms in a row, it would #f, same for two lists. I now need to make it #f for 3 in a row. This is what I did for the first ass.
#lang scheme
(define a (list 1 (list 2 3) 1 (list 2 3) 4)) ;one list
(define b (list (list 2 3) (list 2 3) 4)) ;one list
(define c (list 1 (list 2 3) 1 (list 2 3) 4)) ;one list
(define d (list 1 1 (list 2 3) 1 (list 2 3) 4)) ;one list
(define e (list 1)) ;one list
(define (altlis lis1)
(if (list? (car lis1))
(if (list? (car(cdr lis1)))
(quote(false))
(altlis (cdr lis1)
)
)
(if (null? (cdr lis1)) (quote(true))
(if (list? (car(cdr lis1)))
(altlis (cdr lis1))
(quote(false)))
)
)
)
(altlis e)
I cannot figure this out to catch the third one, any help will be appreciate it as I have NO experience with scheme prior to this class I am taking.
Thanks