Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. (define fill 0)
  2. (define (make-multi-vector sizes . args)
  3. (if (not (null? args))
  4. (begin
  5. (set! fill (car args))
  6. (make-multi-vector+ sizes fill))
  7. (if (not (null? sizes))
  8. (cons (make-vector (car sizes)) (make-multi-vector (cdr sizes)))
  9. '())))
  10. (define (make-multi-vector+ sizes fill)
  11. (if (not (null? sizes))
  12. (cons (make-vector (car sizes) fill) (make-multi-vector (cdr sizes) fill))
  13. '()))
  14. (define (multi-vector? m)
  15. (if (list? m)
  16. (if (and (vector? (car m)) (vector? (car (cdr m))))
  17. (= 1 1)
  18. (= 1 2))
  19. (= 1 2)))
  20. (define (multi-vector-set! m indices x)
  21. (if (or (not (null? indices)) (not (null? m)))
  22. (if (list? m)
  23. (cons (vector-set! (car m) (car indices) x) (multi-vector-set! (cdr m) (cdr indices) x))
  24. '())
  25. '()))
  26. (define (multi-vector-ref m indices)
  27. (if (or (not (null? (cdr indices))) (not (null? (cdr m))))
  28. (if (list? m)
  29. (multi-vector-ref (cdr m) (cdr indices)))
  30. '())
  31. (vector-ref (car m) (car indices)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement