Im writing two scheme , but i run into some problems.. im using Dr.Schme.. and im limited only to use use the following pre-defined Scheme procedures : define, lambda, cond (including the else notation), if, cons, car, cdr, null?, =, equal?, list?, odd?, and, or, not, +, -, *, /, <, <=, >, >=
And i can't figure out how to get this one ..
(calc-depth L) takes a list L and returns its depth. The depth of a list is defined as the maximum level of nesting of a list.
(calc-depth '( )) => 1
(calc-depth '(1 2 3)) => 1
(calc-depth '(1 (2) 3)) => 2
(calc-depth '(1 (2 (3) 4) 5)) => 3
and aslo this one ..
(deep-reverse L) takes a list L and returns the deep reversal of L. The deep reversal of L is a list R that contains all of the elements of L in reverse order. Further, for each element L' in L which is a list, the corresponding element in R is the "deep reversal" of L'.
(deep-reverse '( )) => ( )
(deep-reverse '(a b c)) => (c b a)
(deep-reverse '((a b c) d ((e f) g))) => ((g (f e)) d (c b a))
im totally lost and i tried so many different combo and it still doesn't work .. any help would be appricated ;]
And i can't figure out how to get this one ..
(calc-depth L) takes a list L and returns its depth. The depth of a list is defined as the maximum level of nesting of a list.
(calc-depth '( )) => 1
(calc-depth '(1 2 3)) => 1
(calc-depth '(1 (2) 3)) => 2
(calc-depth '(1 (2 (3) 4) 5)) => 3
and aslo this one ..
(deep-reverse L) takes a list L and returns the deep reversal of L. The deep reversal of L is a list R that contains all of the elements of L in reverse order. Further, for each element L' in L which is a list, the corresponding element in R is the "deep reversal" of L'.
(deep-reverse '( )) => ( )
(deep-reverse '(a b c)) => (c b a)
(deep-reverse '((a b c) d ((e f) g))) => ((g (f e)) d (c b a))
im totally lost and i tried so many different combo and it still doesn't work .. any help would be appricated ;]