Advertisement
Guest User

Untitled

a guest
May 27th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. ;;***KOLEJKA************************************************************
  2. ;;Implementacja Kolejki
  3. (define-unit bag-fifo@
  4. (import)
  5. (export bag^)
  6.  
  7. (define (bag? x)
  8. (and (list? x)
  9. (eq? (length x) 2)
  10. (eq? (car x) 'bag-fifo)))
  11.  
  12. (define (bag-empty? x)
  13. (eq? (bag-fifo x) '()))
  14.  
  15. (define (bag-fifo x) (cadr x))
  16. (define (bag-cons l) (list 'bag-fifo l))
  17.  
  18. (define empty-bag (bag-cons '()))
  19.  
  20. (define (bag-peek x) (car (reverse (bag-fifo x))))
  21.  
  22. (define (bag-remove x)
  23. (bag-cons (reverse (cdr (reverse (bag-fifo x))))))
  24.  
  25. (define (bag-insert x v)
  26. (bag-cons (cons v (bag-fifo x)))))
  27.  
  28. ;;Otwarcie implamentacji Kolejki
  29. (define-values/invoke-unit/infer bag-fifo@)
  30.  
  31. (define my-fifo empty-bag)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement