Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.87 KB | None | 0 0
  1. (define (merge-lists a b)
  2.   (cond  ((and(null? a) (null? b)) '())
  3.          ((and (not (null? a)) (null? b)) a)
  4.          ((and (null? a) (not (null? b))) b)
  5.          (#t
  6.           (if (< (car a) (car b))
  7.               (cons (car a) (merge-lists (cdr a) b))
  8.               (cons (car b) (merge-lists a (cdr b)))))))
  9.  
  10. (define foo2 '(1 3 4 7))
  11. (define foo1 '(2 5 8 9))
  12.  
  13.  
  14.  
  15. (define (delenie l)
  16.   (delenie-loop '() '() l))
  17.  
  18. ;(define (delenie-loop left right total)
  19. ;  (cond [(null? total) (list left right)]
  20. ;        [(null? (cdr total)) (list (cons (car total) left) right)]
  21. ;        [#t  (delenie-loop (cons (car total) left) (cons (cadr total) right)  (cddr total))]))
  22.  
  23.  
  24. (define (delenie-loop left right total)
  25.   (if (null? total)
  26.       (list left right)
  27.       (delenie-loop right (cons (car total) left) (cdr total))))
  28.  
  29. (display (delenie (list 1 2 3 4 5 6 7)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement