Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (merge-lists a b)
- (cond ((and(null? a) (null? b)) '())
- ((and (not (null? a)) (null? b)) a)
- ((and (null? a) (not (null? b))) b)
- (#t
- (if (< (car a) (car b))
- (cons (car a) (merge-lists (cdr a) b))
- (cons (car b) (merge-lists a (cdr b)))))))
- (define foo2 '(1 3 4 7))
- (define foo1 '(2 5 8 9))
- (define (delenie l)
- (delenie-loop '() '() l))
- ;(define (delenie-loop left right total)
- ; (cond [(null? total) (list left right)]
- ; [(null? (cdr total)) (list (cons (car total) left) right)]
- ; [#t (delenie-loop (cons (car total) left) (cons (cadr total) right) (cddr total))]))
- (define (delenie-loop left right total)
- (if (null? total)
- (list left right)
- (delenie-loop right (cons (car total) left) (cdr total))))
- (display (delenie (list 1 2 3 4 5 6 7)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement